From: Simon Horman <horms@kernel.org>
To: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: netdev@vger.kernel.org, Jiri Pirko <jiri@resnulli.us>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Alexandre Ferrieux <alexandre.ferrieux@gmail.com>,
stable@vger.kernel.org, Sashiko <sashiko-bot@kernel.org>,
Victor Nogueira <victor@mojatatu.com>,
hybris <hybris@mojatatu.ai>
Subject: Re: [PATCH net 1/2] net/sched: cls_u32: fix manual hash table handle IDR aliasing
Date: Thu, 17 Sep 2026 13:08:01 +0100 [thread overview]
Message-ID: <20260917120801.GA51261@horms.kernel.org> (raw)
In-Reply-To: <QDISC-LQFE.v1.20260911041746.1@mojatatu.com>
On Wed, Sep 16, 2026 at 06:01:14AM -0400, Jamal Hadi Salim wrote:
> A u32 hash table created with an explicit handle ('tc filter add ...
> handle 801: u32 divisor N') keys its IDR entry on the raw handle, while
> the destroy paths free it under handle2id(handle). The two key domains
> disagree for handles in the 0x800..0xFFF htid range:
> handle2id() folds them back into the auto-allocated id space (1..0x7FF).
>
> A manual table therefore leaves its raw-keyed IDR entry unreachable on
> delete (a permanent leak), and its delete can drop the idr entry of an
> unrelated live auto table. A later auto allocation can then hand out a
> handle that aliases the live manual table; u32_lookup_ht() first-match
> routes lookups and TCA_U32_LINK for that htid to the wrong table.
>
> Key the divisor-path alloc on handle2id(handle) so allocation and
> removal share one key domain. A manual handle that maps onto an id
> already in use is rejected with -ENOSPC, and auto allocation skips ids
> held by live manual tables.
>
> Conditions to recreate:
> ip link add test0 type dummy
> tc qdisc add dev test0 clsact
> tc filter add dev test0 ingress protocol ip pref 1 \
> handle 801: u32 divisor 16
> tc filter add dev test0 ingress protocol ip pref 2 u32 divisor 16
> tc -d filter show dev test0 ingress | grep 'fh 801:'
> # unpatched: two live tables with handle 0x80100000 (the pref 2 root
> # hnode is auto-allocated id 1); patched: the auto hnode takes id 2.
>
> Also tested with a poc with a live u32 table on the block, add/delete a manual
> table 'handle 901: u32 divisor 1' twice; unpatched, the re-add fails with
> -ENOSPC because the raw key leaked on the first delete.
>
> Fixes: 73af53d82076 ("net: sched: cls_u32: Fix u32's systematic failure to free IDR entries for hnodes.")
> Reported-by: Sashiko (gemini + nipa) <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/20260822222049.114526-1-jhs@mojatatu.com
> Reviewed-by: Victor Nogueira <victor@mojatatu.com>
> Tested-by: hybris <hybris@mojatatu.ai>
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Reviewed-by: Simon Horman <horms@kernel.org>
next prev parent reply other threads:[~2026-09-17 12:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 10:01 [PATCH net 1/2] net/sched: cls_u32: fix manual hash table handle IDR aliasing Jamal Hadi Salim
2026-09-16 10:01 ` [PATCH net 2/2] selftests/tc-testing: add u32 manual table handle IDR tests Jamal Hadi Salim
2026-09-17 12:08 ` Simon Horman
2026-09-17 12:08 ` Simon Horman [this message]
2026-09-18 5:37 ` [PATCH net 1/2] net/sched: cls_u32: fix manual hash table handle IDR aliasing Alexandre Ferrieux
2026-09-18 8:22 ` Jamal Hadi Salim
2026-09-18 9:34 ` Alexandre Ferrieux
2026-09-18 0:10 ` 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=20260917120801.GA51261@horms.kernel.org \
--to=horms@kernel.org \
--cc=alexandre.ferrieux@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hybris@mojatatu.ai \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sashiko-bot@kernel.org \
--cc=stable@vger.kernel.org \
--cc=victor@mojatatu.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.