mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: syzbot <syzbot+ed43b6903ab968b16f54@syzkaller.appspotmail.com>,
	davem@davemloft.net, jhs@mojatatu.com, jiri@resnulli.us,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	syzkaller-bugs@googlegroups.com, xiyou.wangcong@gmail.com
Subject: Re: KASAN: use-after-free Read in pfifo_fast_enqueue
Date: Wed, 14 Mar 2018 17:47:11 -0700	[thread overview]
Message-ID: <0ffb86a8-a316-f2a2-829e-6dc471122f3b@gmail.com> (raw)
In-Reply-To: <a37dbc2c-2c43-2f71-7b36-275fcee83eb1@gmail.com>



On 03/14/2018 05:16 PM, Eric Dumazet wrote:

> 
> typical use after free...
> 
> diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
> index 190570f21b208d5a17943360a3a6f85e1c2a2187..663e016491773f40f81d9bbfeab3dd68e1c2fc5c 100644
> --- a/net/sched/sch_generic.c
> +++ b/net/sched/sch_generic.c
> @@ -628,6 +628,7 @@ static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc,
>         int band = prio2band[skb->priority & TC_PRIO_MAX];
>         struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
>         struct skb_array *q = band2list(priv, band);
> +       unsigned int pkt_len = qdisc_pkt_len(skb);
>         int err;
>  
>         err = skb_array_produce(q, skb);
> @@ -636,7 +637,7 @@ static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc,
>                 return qdisc_drop_cpu(skb, qdisc, to_free);
>  
>         qdisc_qstats_cpu_qlen_inc(qdisc);
> -       qdisc_qstats_cpu_backlog_inc(qdisc, skb);
> +       this_cpu_add(qdisc->cpu_qstats->backlog, pkt_len);
>         return NET_XMIT_SUCCESS;
>  }
> 
There is also a similar issue right after qdisc_enqueue_skb_bad_txq() call.

We should move the following code in qdisc_enqueue_skb_bad_txq() to benefit from the locking

                       if (qdisc_is_percpu_stats(q)) {
                               qdisc_qstats_cpu_backlog_inc(q, nskb);
                               qdisc_qstats_cpu_qlen_inc(q);
                       } else {
                               qdisc_qstats_backlog_inc(q, nskb);
                               q->q.qlen++;
                       }


I will post a patch with the two fixes.

  reply	other threads:[~2018-03-15  0:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <000000000000081c6a056767c154@google.com>
2018-03-15  0:16 ` Eric Dumazet
2018-03-15  0:47   ` Eric Dumazet [this message]
2018-01-16 18:29 syzbot

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=0ffb86a8-a316-f2a2-829e-6dc471122f3b@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=syzbot+ed43b6903ab968b16f54@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=xiyou.wangcong@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®