* [Patch net v2] net_sched: let qdisc_put() accept NULL pointer
@ 2019-09-12 17:22 Cong Wang
2019-09-12 20:30 ` Jiri Pirko
2019-09-15 18:55 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Cong Wang @ 2019-09-12 17:22 UTC (permalink / raw)
To: netdev
Cc: Cong Wang, syzbot+d5870a903591faaca4ae, Linus Torvalds,
Jamal Hadi Salim, Jiri Pirko
When tcf_block_get() fails in sfb_init(), q->qdisc is still a NULL
pointer which leads to a crash in sfb_destroy(). Similar for
sch_dsmark.
Instead of fixing each separately, Linus suggested to just accept
NULL pointer in qdisc_put(), which would make callers easier.
(For sch_dsmark, the bug probably exists long before commit
6529eaba33f0.)
Fixes: 6529eaba33f0 ("net: sched: introduce tcf block infractructure")
Reported-by: syzbot+d5870a903591faaca4ae@syzkaller.appspotmail.com
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
net/sched/sch_generic.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index ac28f6a5d70e..17bd8f539bc7 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -985,6 +985,9 @@ static void qdisc_destroy(struct Qdisc *qdisc)
void qdisc_put(struct Qdisc *qdisc)
{
+ if (!qdisc)
+ return;
+
if (qdisc->flags & TCQ_F_BUILTIN ||
!refcount_dec_and_test(&qdisc->refcnt))
return;
--
2.21.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Patch net v2] net_sched: let qdisc_put() accept NULL pointer
2019-09-12 17:22 [Patch net v2] net_sched: let qdisc_put() accept NULL pointer Cong Wang
@ 2019-09-12 20:30 ` Jiri Pirko
2019-09-15 18:55 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2019-09-12 20:30 UTC (permalink / raw)
To: Cong Wang
Cc: netdev, syzbot+d5870a903591faaca4ae, Linus Torvalds,
Jamal Hadi Salim
Thu, Sep 12, 2019 at 07:22:30PM CEST, xiyou.wangcong@gmail.com wrote:
>When tcf_block_get() fails in sfb_init(), q->qdisc is still a NULL
>pointer which leads to a crash in sfb_destroy(). Similar for
>sch_dsmark.
>
>Instead of fixing each separately, Linus suggested to just accept
>NULL pointer in qdisc_put(), which would make callers easier.
>
>(For sch_dsmark, the bug probably exists long before commit
>6529eaba33f0.)
>
>Fixes: 6529eaba33f0 ("net: sched: introduce tcf block infractructure")
>Reported-by: syzbot+d5870a903591faaca4ae@syzkaller.appspotmail.com
>Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
>Cc: Jamal Hadi Salim <jhs@mojatatu.com>
>Cc: Jiri Pirko <jiri@resnulli.us>
>Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch net v2] net_sched: let qdisc_put() accept NULL pointer
2019-09-12 17:22 [Patch net v2] net_sched: let qdisc_put() accept NULL pointer Cong Wang
2019-09-12 20:30 ` Jiri Pirko
@ 2019-09-15 18:55 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-09-15 18:55 UTC (permalink / raw)
To: xiyou.wangcong; +Cc: netdev, syzbot+d5870a903591faaca4ae, torvalds, jhs, jiri
From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Thu, 12 Sep 2019 10:22:30 -0700
> When tcf_block_get() fails in sfb_init(), q->qdisc is still a NULL
> pointer which leads to a crash in sfb_destroy(). Similar for
> sch_dsmark.
>
> Instead of fixing each separately, Linus suggested to just accept
> NULL pointer in qdisc_put(), which would make callers easier.
>
> (For sch_dsmark, the bug probably exists long before commit
> 6529eaba33f0.)
>
> Fixes: 6529eaba33f0 ("net: sched: introduce tcf block infractructure")
> Reported-by: syzbot+d5870a903591faaca4ae@syzkaller.appspotmail.com
> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-15 18:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-12 17:22 [Patch net v2] net_sched: let qdisc_put() accept NULL pointer Cong Wang
2019-09-12 20:30 ` Jiri Pirko
2019-09-15 18:55 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).