From mboxrd@z Thu Jan 1 00:00:00 1970 From: Changli Gao Subject: Re: [PATCH] IPVS: replace sprintf to snprintf to avoid stack buffer overflow Date: Tue, 6 Apr 2010 10:58:28 +0800 Message-ID: References: <20100406025020.GA2741@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, wensong@linux-vs.org, netdev@vger.kernel.org, lvs-devel@vger.kernel.org To: wzt.wzt@gmail.com Return-path: Received: from mail-yx0-f200.google.com ([209.85.210.200]:39292 "EHLO mail-yx0-f200.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757168Ab0DFC6t convert rfc822-to-8bit (ORCPT ); Mon, 5 Apr 2010 22:58:49 -0400 In-Reply-To: <20100406025020.GA2741@localhost.localdomain> Sender: netdev-owner@vger.kernel.org List-ID: On Tue, Apr 6, 2010 at 10:50 AM, wrote: > IPVS not check the length of pp->name, use sprintf will cause stack b= uffer overflow. > struct ip_vs_protocol{} declare name as char *, if register a protoco= l as: > struct ip_vs_protocol ip_vs_test =3D { > =C2=A0 =C2=A0 =C2=A0 =C2=A0.name =3D =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 "aaaaaaaa....128...aaa", > =C2=A0 =C2=A0 =C2=A0 =C2=A0.debug_packet =3D =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ip_vs_tcpudp_debug_packet, > }; > > when called ip_vs_tcpudp_debug_packet(), sprintf(buf, "%s TRUNCATED",= pp->name); > will cause stack buffer overflow. > Long messages will be truncated instead of buffer overflow. We need to find a way to handle long messages elegantly. --=20 Regards=EF=BC=8C Changli Gao(xiaosuo@gmail.com)