]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
netem: Update sch->q.qlen before qdisc_tree_reduce_backlog()
authorCong Wang <cong.wang@bytedance.com>
Tue, 4 Feb 2025 00:58:40 +0000 (16:58 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Feb 2025 09:05:01 +0000 (10:05 +0100)
[ 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>
net/sched/sch_netem.c

index 3b519adc01259fa32d6600eae2902e0f8d4e18ec..68a08f6d1fbce275bd36812766cd0e51195a8616 100644 (file)
@@ -748,9 +748,9 @@ deliver:
                                if (err != NET_XMIT_SUCCESS) {
                                        if (net_xmit_drop_count(err))
                                                qdisc_qstats_drop(sch);
-                                       qdisc_tree_reduce_backlog(sch, 1, pkt_len);
                                        sch->qstats.backlog -= pkt_len;
                                        sch->q.qlen--;
+                                       qdisc_tree_reduce_backlog(sch, 1, pkt_len);
                                }
                                goto tfifo_dequeue;
                        }