]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net_sched: ets: Fix double list add in class with netem as child qdisc
authorVictor Nogueira <victor@mojatatu.com>
Fri, 25 Apr 2025 22:07:07 +0000 (19:07 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 May 2025 07:43:59 +0000 (09:43 +0200)
commit72c3da7e6ceb74e74ddbb5a305a35c9fdfcac6e3
treed41f89e2204f191d2f1bf81d082fb80d73be7e2e
parent6082a87af4c52f58150d40dec1716011d871ac21
net_sched: ets: Fix double list add in class with netem as child qdisc

[ Upstream commit 1a6d0c00fa07972384b0c308c72db091d49988b6 ]

As described in Gerrard's report [1], there are use cases where a netem
child qdisc will make the parent qdisc's enqueue callback reentrant.
In the case of ets, there won't be a UAF, but the code will add the same
classifier to the list twice, which will cause memory corruption.

In addition to checking for qlen being zero, this patch checks whether
the class was already added to the active_list (cl_is_active) before
doing the addition to cater for the reentrant case.

[1] https://lore.kernel.org/netdev/CAHcdcOm+03OD2j6R0=YHKqmy=VgJ8xEOKuP6c7mSgnp-TEJJbw@mail.gmail.com/

Fixes: 37d9cf1a3ce3 ("sched: Fix detection of empty queues in child qdiscs")
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Victor Nogueira <victor@mojatatu.com>
Link: https://patch.msgid.link/20250425220710.3964791-4-victor@mojatatu.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sched/sch_ets.c