Skip to content

Commit aea28be

Browse files
edumazetSasha Levin
authored andcommitted
net_sched: prio: fix a race in prio_tune()
[ Upstream commit d35acc1 ] Gerrard Tai reported a race condition in PRIO, whenever SFQ perturb timer fires at the wrong time. The race is as follows: CPU 0 CPU 1 [1]: lock root [2]: qdisc_tree_flush_backlog() [3]: unlock root | | [5]: lock root | [6]: rehash | [7]: qdisc_tree_reduce_backlog() | [4]: qdisc_put() This can be abused to underflow a parent's qlen. Calling qdisc_purge_queue() instead of qdisc_tree_flush_backlog() should fix the race, because all packets will be purged from the qdisc before releasing the lock. Fixes: 7b8e0b6 ("net: sched: prio: delay destroying child qdiscs on change") Reported-by: Gerrard Tai <[email protected]> Suggested-by: Gerrard Tai <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 2cbdbd8 commit aea28be

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/sched/sch_prio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static int prio_tune(struct Qdisc *sch, struct nlattr *opt,
211211
memcpy(q->prio2band, qopt->priomap, TC_PRIO_MAX+1);
212212

213213
for (i = q->bands; i < oldbands; i++)
214-
qdisc_tree_flush_backlog(q->queues[i]);
214+
qdisc_purge_queue(q->queues[i]);
215215

216216
for (i = oldbands; i < q->bands; i++) {
217217
q->queues[i] = queues[i];

0 commit comments

Comments
 (0)