Skip to content

Commit 58bae91

Browse files
committed
Merge branch 'net-sched-teql-enforce-hierarchy-placement'
Jamal Hadi Salim says: ==================== net/sched: teql: Enforce hierarchy placement GangMin Kim <km.kim1503@gmail.com> managed to create a UAF on qfq by inserting teql as a child qdisc and exploiting a qlen sync issue. teql is not intended to be used as a child qdisc. Lets enforce that rule in patch #1. Although patch #1 fixes the issue, we prevent another potential qlen exploit in qfq in patch #2 by enforcing the child's active status is not determined by inspecting the qlen. In patch #3 we add a tdc test case. ==================== Link: https://patch.msgid.link/20260114160243.913069-1-jhs@mojatatu.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 3ddf446 + 2460f31 commit 58bae91

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

net/sched/sch_qfq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ static void qfq_rm_from_agg(struct qfq_sched *q, struct qfq_class *cl)
373373
/* Deschedule class and remove it from its parent aggregate. */
374374
static void qfq_deact_rm_from_agg(struct qfq_sched *q, struct qfq_class *cl)
375375
{
376-
if (cl->qdisc->q.qlen > 0) /* class is active */
376+
if (cl_is_active(cl)) /* class is active */
377377
qfq_deactivate_class(q, cl);
378378

379379
qfq_rm_from_agg(q, cl);

net/sched/sch_teql.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt,
178178
if (m->dev == dev)
179179
return -ELOOP;
180180

181+
if (sch->parent != TC_H_ROOT) {
182+
NL_SET_ERR_MSG_MOD(extack, "teql can only be used as root");
183+
return -EOPNOTSUPP;
184+
}
185+
181186
q->m = m;
182187

183188
skb_queue_head_init(&q->q);

tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,30 @@
8181
"$TC qdisc del dev $DUMMY handle 1: root",
8282
"$IP link del dev $DUMMY"
8383
]
84+
},
85+
{
86+
"id": "124e",
87+
"name": "Try to add teql as a child qdisc",
88+
"category": [
89+
"qdisc",
90+
"ets",
91+
"tbf"
92+
],
93+
"plugins": {
94+
"requires": [
95+
"nsPlugin"
96+
]
97+
},
98+
"setup": [
99+
"$TC qdisc add dev $DUMMY root handle 1: qfq",
100+
"$TC class add dev $DUMMY parent 1: classid 1:1 qfq weight 15 maxpkt 16384"
101+
],
102+
"cmdUnderTest": "$TC qdisc add dev $DUMMY parent 1:1 handle 2:1 teql0",
103+
"expExitCode": "2",
104+
"verifyCmd": "$TC -s -j qdisc ls dev $DUMMY parent 1:1",
105+
"matchJSON": [],
106+
"teardown": [
107+
"$TC qdisc del dev $DUMMY root handle 1:"
108+
]
84109
}
85110
]

0 commit comments

Comments
 (0)