public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Eric Dumazet <edumazet@google.com>,
	"David S . Miller" <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	Jamal Hadi Salim <jhs@mojatatu.com>
Subject: Re: [PATCH v2 net] net: sched: fix uses after free
Date: Wed, 14 Mar 2018 22:19:38 -0700	[thread overview]
Message-ID: <c2c0d3f2-388f-2e56-73aa-74eb2163e91d@gmail.com> (raw)
In-Reply-To: <5b7c5a08-4225-9f20-2a2c-57767a36a967@gmail.com>

On 03/14/2018 08:10 PM, John Fastabend wrote:
> On 03/14/2018 06:53 PM, Eric Dumazet wrote:
>> syzbot reported one use-after-free in pfifo_fast_enqueue() [1]
>>
>> Issue here is that we can not reuse skb after a successful skb_array_produce()
>> since another cpu might have consumed it already.
>>
>> I believe a similar problem exists in try_bulk_dequeue_skb_slow()
>> in case we put an skb into qdisc_enqueue_skb_bad_txq() for lockless qdisc.
>>
> 
> [...]
> 
>> Fixes: c5ad119fb6c0 ("net: sched: pfifo_fast use skb_array")
>> Signed-off-by: Eric Dumazet <edumazet@google.com>
>> Reported-by: syzbot+ed43b6903ab968b16f54@syzkaller.appspotmail.com
>> Cc: John Fastabend <john.fastabend@gmail.com>
>> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
>> Cc:	Cong Wang <xiyou.wangcong@gmail.com>
>> Cc:	Jiri Pirko <jiri@resnulli.us>
>> ---
>>  net/sched/sch_generic.c | 22 +++++++++++++---------
>>  1 file changed, 13 insertions(+), 9 deletions(-)
>>
> 
> Thanks!
> 
> Acked-by: John Fastabend <john.fastabend@gmail.com>
> 
>> diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
>> index 190570f21b208d5a17943360a3a6f85e1c2a2187..7e3fbe9cc936be376b66a5b12bf8957c3b601f2c 100644
>> --- a/net/sched/sch_generic.c
>> +++ b/net/sched/sch_generic.c
>> @@ -106,6 +106,14 @@ static inline void qdisc_enqueue_skb_bad_txq(struct Qdisc *q,
>>  
>>  	__skb_queue_tail(&q->skb_bad_txq, skb);
>>  
>> +	if (qdisc_is_percpu_stats(q)) {
>> +		qdisc_qstats_cpu_backlog_inc(q, skb);
> 
> So I guess the skb access above needs to be removed as
> well per your comment in the commit description. But that
> can be another patch.
> 

Actually this is fine I read this too quickly on first
read.

Sorry for the noise.  Looks good to me. 

>> +		qdisc_qstats_cpu_qlen_inc(q);
>> +	} else {
>> +		qdisc_qstats_backlog_inc(q, skb);
>> +		q->q.qlen++;
>> +	}
>> +
>>  	if (lock)
>>  		spin_unlock(lock);
>>  }
> 
> 

  reply	other threads:[~2018-03-15  5:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-15  1:53 [PATCH v2 net] net: sched: fix uses after free Eric Dumazet
2018-03-15  3:10 ` John Fastabend
2018-03-15  5:19   ` John Fastabend [this message]
2018-03-17 21:04 ` 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=c2c0d3f2-388f-2e56-73aa-74eb2163e91d@gmail.com \
    --to=john.fastabend@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    /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