[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120430092509.54b89ae6@nehalam.linuxnetplumber.net>
Date: Mon, 30 Apr 2012 09:25:09 -0700
From: Stephen Hemminger <shemminger@...tta.com>
To: Eric Dumazet <eric.dumazet@...il.com>
Cc: David Miller <davem@...emloft.net>,
netdev <netdev@...r.kernel.org>,
Stephen Hemminger <shemminger@...l.org>
Subject: Re: [PATCH] netem: fix possible skb leak
On Sun, 29 Apr 2012 21:08:22 +0200
Eric Dumazet <eric.dumazet@...il.com> wrote:
> From: Eric Dumazet <edumazet@...gle.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@...gle.com>
> Cc: Stephen Hemminger <shemminger@...l.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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists