Skip to content

Commit 0c3057a

Browse files
congwangkuba-moo
authored andcommitted
net_sched: Prevent creation of classes with TC_H_ROOT
The function qdisc_tree_reduce_backlog() uses TC_H_ROOT as a termination condition when traversing up the qdisc tree to update parent backlog counters. However, if a class is created with classid TC_H_ROOT, the traversal terminates prematurely at this class instead of reaching the actual root qdisc, causing parent statistics to be incorrectly maintained. In case of DRR, this could lead to a crash as reported by Mingi Cho. Prevent the creation of any Qdisc class with classid TC_H_ROOT (0xFFFFFFFF) across all qdisc types, as suggested by Jamal. Reported-by: Mingi Cho <[email protected]> Signed-off-by: Cong Wang <[email protected]> Reviewed-by: Simon Horman <[email protected]> Fixes: 066a3b5 ("[NET_SCHED] sch_api: fix qdisc_tree_decrease_qlen() loop") Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 081b575 commit 0c3057a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/sched/sch_api.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,6 +2254,12 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n,
22542254
return -EOPNOTSUPP;
22552255
}
22562256

2257+
/* Prevent creation of traffic classes with classid TC_H_ROOT */
2258+
if (clid == TC_H_ROOT) {
2259+
NL_SET_ERR_MSG(extack, "Cannot create traffic class with classid TC_H_ROOT");
2260+
return -EINVAL;
2261+
}
2262+
22572263
new_cl = cl;
22582264
err = -EOPNOTSUPP;
22592265
if (cops->change)

0 commit comments

Comments
 (0)