From: Lion Ackermann <nnamrec@gmail.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, Jamal Hadi Salim <jhs@mojatatu.com>,
Jiri Pirko <jiri@resnulli.us>
Subject: Re: Incomplete fix for recent bug in tc / hfsc
Date: Tue, 24 Jun 2025 11:24:20 +0200 [thread overview]
Message-ID: <3af4930b-6773-4159-8a7a-e4f6f6ae8109@gmail.com> (raw)
In-Reply-To: <aFosjBOUlOr0TKsd@pop-os.localdomain>
Hi,
On 6/24/25 6:41 AM, Cong Wang wrote:
> On Mon, Jun 23, 2025 at 12:41:08PM +0200, Lion Ackermann wrote:
>> Hello,
>>
>> I noticed the fix for a recent bug in sch_hfsc in the tc subsystem is
>> incomplete:
>> sch_hfsc: Fix qlen accounting bug when using peek in hfsc_enqueue()
>> https://lore.kernel.org/all/20250518222038.58538-2-xiyou.wangcong@gmail.com/
>>
>> This patch also included a test which landed:
>> selftests/tc-testing: Add an HFSC qlen accounting test
>>
>> Basically running the included test case on a sanitizer kernel or with
>> slub_debug=P will directly reveal the UAF:
>
> Interesting, I have SLUB debugging enabled in my kernel config too:
>
> CONFIG_SLUB_DEBUG=y
> CONFIG_SLUB_DEBUG_ON=y
> CONFIG_SLUB_RCU_DEBUG=y
>
> But I didn't catch this bug.
>
Technically the class deletion step which triggered the sanitizer was not
present in your testcase. The testcase only left the stale pointer which was
never accessed though.
>> To be completely honest I do not quite understand the rationale behind the
>> original patch. The problem is that the backlog corruption propagates to
>> the parent _before_ parent is even expecting any backlog updates.
>> Looking at f.e. DRR: Child is only made active _after_ the enqueue completes.
>> Because HFSC is messing with the backlog before the enqueue completed,
>> DRR will simply make the class active even though it should have already
>> removed the class from the active list due to qdisc_tree_backlog_flush.
>> This leaves the stale class in the active list and causes the UAF.
>>
>> Looking at other qdiscs the way DRR handles child enqueues seems to resemble
>> the common case. HFSC calling dequeue in the enqueue handler violates
>> expectations. In order to fix this either HFSC has to stop using dequeue or
>> all classful qdiscs have to be updated to catch this corner case where
>> child qlen was zero even though the enqueue succeeded. Alternatively HFSC
>> could signal enqueue failure if it sees child dequeue dropping packets to
>> zero? I am not sure how this all plays out with the re-entrant case of
>> netem though.
>
> I think this may be the same bug report from Mingi in the security
> mailing list. I will take a deep look after I go back from Open Source
> Summit this week. (But you are still very welcome to work on it by
> yourself, just let me know.)
>
> Thanks!
> My suggestion is we go back to a proposal i made a few moons back (was
> this in a discussion with you? i dont remember): create a mechanism to
> disallow certain hierarchies of qdiscs based on certain attributes,
> example in this case disallow hfsc from being the ancestor of "qdiscs that may
> drop during peek" (such as netem). Then we can just keep adding more
> "disallowed configs" that will be rejected via netlink. Similar idea
> is being added to netem to disallow double duplication, see:
> https://lore.kernel.org/netdev/20250622190344.446090-1-will@willsroot.io/
>
> cheers,
> jamal
I vaguely remember Jamal's proposal from a while back, and I believe there was
some example code for this approach already?
Since there is another report you have a better overview, so it is probably
best you look at it first. In the meantime I can think about the solution a
bit more and possibly draft something if you wish.
Thanks,
Lion
next prev parent reply other threads:[~2025-06-24 9:24 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-23 10:41 Incomplete fix for recent bug in tc / hfsc Lion Ackermann
2025-06-23 14:43 ` Jamal Hadi Salim
2025-06-24 4:41 ` Cong Wang
2025-06-24 9:24 ` Lion Ackermann [this message]
2025-06-24 10:43 ` Lion Ackermann
2025-06-25 14:22 ` Jamal Hadi Salim
2025-06-26 8:08 ` Lion Ackermann
2025-06-28 21:43 ` Jamal Hadi Salim
2025-06-29 14:29 ` Jamal Hadi Salim
2025-06-29 19:50 ` Cong Wang
2025-06-30 9:04 ` Lion Ackermann
2025-06-30 11:34 ` Jamal Hadi Salim
2025-06-30 13:36 ` Lion Ackermann
2025-06-30 14:57 ` Jamal Hadi Salim
2025-06-30 17:52 ` Victor Nogueira
2025-06-30 21:42 ` Cong Wang
2025-07-01 12:41 ` Lion Ackermann
2025-07-01 12:58 ` Victor Nogueira
2025-06-30 11:47 ` Victor Nogueira
2025-06-30 13:27 ` [PATCH] net/sched: Always pass notifications when child class becomes empty Lion Ackermann
2025-06-30 14:56 ` Jamal Hadi Salim
2025-06-30 21:38 ` Cong Wang
2025-07-01 14:03 ` Jamal Hadi Salim
2025-07-02 21:50 ` patchwork-bot+netdevbpf
2025-06-28 0:35 ` Incomplete fix for recent bug in tc / hfsc Cong Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3af4930b-6773-4159-8a7a-e4f6f6ae8109@gmail.com \
--to=nnamrec@gmail.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.