* [PATCH] netem: fix possible skb leak
@ 2012-04-29 19:08 Eric Dumazet
2012-04-30 16:25 ` Stephen Hemminger
2012-05-01 17:41 ` David Miller
0 siblings, 2 replies; 5+ messages in thread
From: Eric Dumazet @ 2012-04-29 19:08 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Stephen Hemminger
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);
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] netem: fix possible skb leak
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
2012-05-01 17:41 ` David Miller
1 sibling, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2012-04-30 16:25 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev, Stephen Hemminger
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] netem: fix possible skb leak
2012-04-30 16:25 ` Stephen Hemminger
@ 2012-04-30 16:40 ` Eric Dumazet
2012-04-30 16:44 ` Stephen Hemminger
0 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2012-04-30 16:40 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev, Stephen Hemminger
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 ;)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] netem: fix possible skb leak
2012-04-30 16:40 ` Eric Dumazet
@ 2012-04-30 16:44 ` Stephen Hemminger
0 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2012-04-30 16:44 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev, Stephen Hemminger
On Mon, 30 Apr 2012 18:40:16 +0200
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> 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 ;)
Ok, I am surprised that qdisc_drop() is safe with NULL skb, but yes.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] netem: fix possible skb leak
2012-04-29 19:08 [PATCH] netem: fix possible skb leak Eric Dumazet
2012-04-30 16:25 ` Stephen Hemminger
@ 2012-05-01 17:41 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2012-05-01 17:41 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev, shemminger
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Sun, 29 Apr 2012 21:08:22 +0200
> 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>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-05-01 17:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2012-04-30 16:44 ` Stephen Hemminger
2012-05-01 17:41 ` David Miller
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.