Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: David Miller <davem@davemloft.net>,
	netdev <netdev@vger.kernel.org>,
	Stephen Hemminger <shemminger@osdl.org>
Subject: Re: [PATCH] netem: fix possible skb leak
Date: Mon, 30 Apr 2012 18:40:16 +0200	[thread overview]
Message-ID: <1335804016.2296.5.camel@edumazet-glaptop> (raw)
In-Reply-To: <20120430092509.54b89ae6@nehalam.linuxnetplumber.net>

On Mon, 2012-04-30 at 09:25 -0700, Stephen Hemminger wrote:
> On Sun, 29 Apr 2012 21:08:22 +0200
> Eric Dumazet <eric.dumazet@gmail.com> wrote:
> 
> > From: Eric Dumazet <edumazet@google.com>
> > 
> > skb_checksum_help(skb) can return an error, we must free skb in this
> > case. qdisc_drop(skb, sch) can also be feeded with a NULL skb (if
> > skb_unshare() failed), so lets use this generic helper.
> > 
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
> > Cc: Stephen Hemminger <shemminger@osdl.org>
> > ---
> >  net/sched/sch_netem.c |    6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
> > index 5da548f..ebd2296 100644
> > --- a/net/sched/sch_netem.c
> > +++ b/net/sched/sch_netem.c
> > @@ -408,10 +408,8 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
> >  	if (q->corrupt && q->corrupt >= get_crandom(&q->corrupt_cor)) {
> >  		if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
> >  		    (skb->ip_summed == CHECKSUM_PARTIAL &&
> > -		     skb_checksum_help(skb))) {
> > -			sch->qstats.drops++;
> > -			return NET_XMIT_DROP;
> > -		}
> > +		     skb_checksum_help(skb)))
> > +			return qdisc_drop(skb, sch);
> >  
> >  		skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8);
> >  	}
> > 
> > 
> 
> This would crater if skb_unshare() returned NULL. I think the conditional
> needs to be split into two paths.

Maybe you can read the changelog where I explained this was safe ;)

  reply	other threads:[~2012-04-30 16:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-29 19:08 [PATCH] netem: fix possible skb leak Eric Dumazet
2012-04-30 16:25 ` Stephen Hemminger
2012-04-30 16:40   ` Eric Dumazet [this message]
2012-04-30 16:44     ` Stephen Hemminger
2012-05-01 17:41 ` David Miller

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=1335804016.2296.5.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@osdl.org \
    --cc=shemminger@vyatta.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox