Skip to content

Commit 7b9870f

Browse files
congwanggregkh
authored andcommitted
net_sched: avoid matching qdisc with zero handle
[ Upstream commit 50317fc ] Davide found the following script triggers a NULL pointer dereference: ip l a name eth0 type dummy tc q a dev eth0 parent :1 handle 1: htb This is because for a freshly created netdevice noop_qdisc is attached and when passing 'parent :1', kernel actually tries to match the major handle which is 0 and noop_qdisc has handle 0 so is matched by mistake. Commit 69012ae tries to fix a similar bug but still misses this case. Handle 0 is not a valid one, should be just skipped. In fact, kernel uses it as TC_H_UNSPEC. Fixes: 69012ae ("net: sched: fix handling of singleton qdiscs with qdisc_hash") Fixes: 59cc1f6 ("net: sched:convert qdisc linked list to hashtable") Reported-by: Davide Caratti <dcaratti@redhat.com> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Eric Dumazet <edumazet@google.com> Cc: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b89fc6a commit 7b9870f

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

net/sched/sch_api.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle)
296296
{
297297
struct Qdisc *q;
298298

299+
if (!handle)
300+
return NULL;
299301
q = qdisc_match_from_root(dev->qdisc, handle);
300302
if (q)
301303
goto out;

0 commit comments

Comments
 (0)