Netdev List
 help / color / mirror / Atom feed
* [PATCH] net: sched: sch: null pointer dereference in htb_offload_move_qdisc()
@ 2023-02-16 10:49 Alok Tiwari
  2023-02-16 15:24 ` Larysa Zaremba
  0 siblings, 1 reply; 2+ messages in thread
From: Alok Tiwari @ 2023-02-16 10:49 UTC (permalink / raw)
  To: netdev
  Cc: alok.a.tiwari, darren.kenny, linux-kernel, jhs, xiyou.wangcong,
	jiri, kuba, simon.horman, keescook

A possible case of null pointer dereference detected by static analyzer
htb_destroy_class_offload() is calling htb_find() which can return NULL value
for invalid class id, moved_cl=htb_find(classid, sch);
in that case it should not pass 'moved_cl' to htb_offload_move_qdisc()
if 'moved_cl' is NULL pointer return -EINVAL.

Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
 net/sched/sch_htb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 92f2975b6a82..5a96d9ea3221 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1601,6 +1601,8 @@ static int htb_destroy_class_offload(struct Qdisc *sch, struct htb_class *cl,
 		u32 classid = TC_H_MAJ(sch->handle) |
 			      TC_H_MIN(offload_opt.classid);
 		struct htb_class *moved_cl = htb_find(classid, sch);
+		if (WARN_ON_ONCE(!moved_cl))
+			return -EINVAL;
 
 		htb_offload_move_qdisc(sch, moved_cl, cl, destroying);
 	}
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-16 15:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-16 10:49 [PATCH] net: sched: sch: null pointer dereference in htb_offload_move_qdisc() Alok Tiwari
2023-02-16 15:24 ` Larysa Zaremba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox