netem: Update sch->q.qlen before qdisc_tree_reduce_backlog()
authorSasha Levin <sashal@kernel.org>
Tue, 4 Feb 2025 00:58:40 +0000 (16:58 -0800)
committerBen Hutchings <benh@debian.org>
Mon, 24 Feb 2025 01:11:58 +0000 (02:11 +0100)
commitfb37780ed99b1eeaa5e71845edbe8121365e316b
tree83b658fba9a47a4de021218c101712c26b15a203
parent0f69fccec5599eb9579cd39d61dc4acb183b69a4
netem: Update sch->q.qlen before qdisc_tree_reduce_backlog()

[ Upstream commit 638ba5089324796c2ee49af10427459c2de35f71 ]

qdisc_tree_reduce_backlog() notifies parent qdisc only if child
qdisc becomes empty, therefore we need to reduce the backlog of the
child qdisc before calling it. Otherwise it would miss the opportunity
to call cops->qlen_notify(), in the case of DRR, it resulted in UAF
since DRR uses ->qlen_notify() to maintain its active list.

Fixes: f8d4bc455047 ("net/sched: netem: account for backlog updates from child qdisc")
Cc: Martin Ottens <martin.ottens@fau.de>
Reported-by: Mingi Cho <mincho@theori.io>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Link: https://patch.msgid.link/20250204005841.223511-4-xiyou.wangcong@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name netem-update-sch-q.qlen-before-qdisc_tree_reduce_bac.patch
net/sched/sch_netem.c