Skip to contentSkip to conversation

net_sched: let qdisc_put() accept NULL pointer

PATCH In review Cong Wang 3 participants 3 messages Sep 12, 2019 – Sep 15, 2019

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH v2 1/1 net_sched: let qdisc_put() accept NULL pointer

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 [email protected]
Cc Jamal Hadi Salim <[email protected]>
Cc Jiri Pirko <[email protected]>
---
 net/sched/sch_generic.c | 3 +++
 1 file changed, 3 insertions(+)
net/sched/sch_generic.c +3 -0
index ac28f6a5d70e..17bd8f539bc7 100644
@@ -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;
Signature · 1 line
2.21.0
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 10 lines · Thu, Sep 12, 2019 at 07:22:30PM CEST, [email protected] 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.)

Quoted 6 lines
Fixes 6529eaba33f0 ("net: sched: introduce tcf block infractructure")
Reported-by [email protected]
Cc Jamal Hadi Salim <[email protected]>
Cc Jiri Pirko <[email protected]>

Thanks!

maintainer
#2 lore raw
In reply to Cong Wang

From: Cong Wang <[email protected]>
Date: Thu, 12 Sep 2019 10:22:30 -0700

Quoted 7 lines

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.

Quoted 7 lines

(For sch_dsmark, the bug probably exists long before commit 6529eaba33f0.)

Fixes 6529eaba33f0 ("net: sched: introduce tcf block infractructure")
Reported-by [email protected]

Applied and queued up for -stable, thanks.