All of lore.kernel.org
 help / color / mirror / Atom feed
From: Changli Gao <xiaosuo@gmail.com>
To: wzt.wzt@gmail.com
Cc: linux-kernel@vger.kernel.org, wensong@linux-vs.org,
	netdev@vger.kernel.org, lvs-devel@vger.kernel.org
Subject: Re: [PATCH] IPVS: replace sprintf to snprintf to avoid stack buffer  overflow
Date: Tue, 6 Apr 2010 10:58:28 +0800	[thread overview]
Message-ID: <k2l412e6f7f1004051958h7c50f439r6b7a84379c35cba5@mail.gmail.com> (raw)
In-Reply-To: <20100406025020.GA2741@localhost.localdomain>

On Tue, Apr 6, 2010 at 10:50 AM,  <wzt.wzt@gmail.com> wrote:
> IPVS not check the length of pp->name, use sprintf will cause stack buffer overflow.
> struct ip_vs_protocol{} declare name as char *, if register a protocol as:
> struct ip_vs_protocol ip_vs_test = {
>        .name =                 "aaaaaaaa....128...aaa",
>        .debug_packet =         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.

-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

WARNING: multiple messages have this Message-ID (diff)
From: Changli Gao <xiaosuo@gmail.com>
To: wzt.wzt@gmail.com
Cc: linux-kernel@vger.kernel.org, wensong@linux-vs.org,
	netdev@vger.kernel.org, lvs-devel@vger.kernel.org
Subject: Re: [PATCH] IPVS: replace sprintf to snprintf to avoid stack buffer overflow
Date: Tue, 6 Apr 2010 10:58:28 +0800	[thread overview]
Message-ID: <k2l412e6f7f1004051958h7c50f439r6b7a84379c35cba5@mail.gmail.com> (raw)
In-Reply-To: <20100406025020.GA2741@localhost.localdomain>

On Tue, Apr 6, 2010 at 10:50 AM,  <wzt.wzt@gmail.com> wrote:
> IPVS not check the length of pp->name, use sprintf will cause stack buffer overflow.
> struct ip_vs_protocol{} declare name as char *, if register a protocol as:
> struct ip_vs_protocol ip_vs_test = {
>        .name =                 "aaaaaaaa....128...aaa",
>        .debug_packet =         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.

-- 
Regards,
Changli Gao(xiaosuo@gmail.com)

  reply	other threads:[~2010-04-06  2:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-06  2:50 [PATCH] IPVS: replace sprintf to snprintf to avoid stack buffer overflow wzt.wzt
2010-04-06  2:58 ` Changli Gao [this message]
2010-04-06  2:58   ` Changli Gao
2010-04-06  3:26   ` Simon Horman
2010-04-06  3:22 ` Simon Horman
2010-04-07 16:09   ` Patrick McHardy
2010-04-07 22:34     ` Simon Horman
2010-04-08 11:37       ` Patrick McHardy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=k2l412e6f7f1004051958h7c50f439r6b7a84379c35cba5@mail.gmail.com \
    --to=xiaosuo@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvs-devel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=wensong@linux-vs.org \
    --cc=wzt.wzt@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.