netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Lion Ackermann <nnamrec@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: Mon, 23 Jun 2025 21:41:48 -0700	[thread overview]
Message-ID: <aFosjBOUlOr0TKsd@pop-os.localdomain> (raw)
In-Reply-To: <45876f14-cf28-4177-8ead-bb769fd9e57a@gmail.com>

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.
 
> 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!

  parent reply	other threads:[~2025-06-24  4:41 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 [this message]
2025-06-24  9:24   ` Lion Ackermann
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=aFosjBOUlOr0TKsd@pop-os.localdomain \
    --to=xiyou.wangcong@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=nnamrec@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).