From: Simon Horman <horms@kernel.org>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, jiri@resnulli.us, jhs@mojatatu.com,
Mingi Cho <mincho@theori.io>
Subject: Re: [Patch net 1/2] sch_hfsc: Fix qlen accounting bug when using peek in hfsc_enqueue()
Date: Wed, 21 May 2025 10:18:47 +0100 [thread overview]
Message-ID: <20250521091847.GU365796@horms.kernel.org> (raw)
In-Reply-To: <20250518222038.58538-2-xiyou.wangcong@gmail.com>
On Sun, May 18, 2025 at 03:20:37PM -0700, Cong Wang wrote:
> When enqueuing the first packet to an HFSC class, hfsc_enqueue() calls the
> child qdisc's peek() operation before incrementing sch->q.qlen and
> sch->qstats.backlog. If the child qdisc uses qdisc_peek_dequeued(), this may
> trigger an immediate dequeue and potential packet drop. In such cases,
> qdisc_tree_reduce_backlog() is called, but the HFSC qdisc's qlen and backlog
> have not yet been updated, leading to inconsistent queue accounting. This
> can leave an empty HFSC class in the active list, causing further
> consequences like use-after-free.
>
> This patch fixes the bug by moving the increment of sch->q.qlen and
> sch->qstats.backlog before the call to the child qdisc's peek() operation.
> This ensures that queue length and backlog are always accurate when packet
> drops or dequeues are triggered during the peek.
>
> Fixes: 12d0ad3be9c3 ("net/sched/sch_hfsc.c: handle corner cases where head may change invalidating calculated deadline")
> Reported-by: Mingi Cho <mincho@theori.io>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
next prev parent reply other threads:[~2025-05-21 9:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-18 22:20 [Patch net 0/2] net_sched: Fix HFSC qlen/backlog accounting bug and add selftest Cong Wang
2025-05-18 22:20 ` [Patch net 1/2] sch_hfsc: Fix qlen accounting bug when using peek in hfsc_enqueue() Cong Wang
2025-05-21 9:18 ` Simon Horman [this message]
2025-05-18 22:20 ` [Patch net 2/2] selftests/tc-testing: Add an HFSC qlen accounting test Cong Wang
2025-05-21 9:18 ` Simon Horman
2025-05-21 11:07 ` [Patch net 0/2] net_sched: Fix HFSC qlen/backlog accounting bug and add selftest Jamal Hadi Salim
2025-05-22 9:30 ` patchwork-bot+netdevbpf
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=20250521091847.GU365796@horms.kernel.org \
--to=horms@kernel.org \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=mincho@theori.io \
--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.