From: Paolo Abeni <pabeni@redhat.com>
To: victor@mojatatu.com
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
jhs@mojatatu.com, jiri@resnulli.us, horms@kernel.org,
vega@nebusec.ai, netdev@vger.kernel.org
Subject: Re: [PATCH net v2 2/4] net/sched: cls_route: Reject handle aliasing
Date: Thu, 10 Sep 2026 11:27:09 +0200 [thread overview]
Message-ID: <fd286e60-73c0-4a6f-8861-7f6cbc197cb0@redhat.com> (raw)
In-Reply-To: <178894934962.219967.16944577524953312446@kernel.org>
On 9/9/26 12:22 PM, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider:
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> - [Medium] net/sched/cls_route.c:route4_set_parms() — the duplicate-
> handle scan rewritten by this patch (line 463: `if (fp->handle ==…
>
> --
>
> net/sched: cls_route: Reject handle aliasing
>
> route4_set_parms() scanned the destination chain for the filter's old
> handle instead of the handle it is about to be linked under, so a change
> that moves a filter into a chain already holding nhandle missed the
> collision and created two filters with the same handle. The patch makes
> the scan compare against nhandle and adds an extack message.
>
> Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260829205422.854785-1-victor%40mojatatu.com
>
>> diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
>> index 17b0ebb766626..9710b77d379c4 100644
>> --- a/net/sched/cls_route.c
>> +++ b/net/sched/cls_route.c
>> @@ -460,8 +460,12 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,
>> for (fp = rtnl_dereference(b->ht[h2]);
>> fp;
>> fp = rtnl_dereference(fp->next))
>> - if (fp->handle == f->handle)
>> + if (fp->handle == nhandle) {
>> + NL_SET_ERR_MSG_FMT(extack,
>> + "Handle %x is already in use",
>> + nhandle);
>> return -EEXIST;
>> + }
>
> [Severity: Medium]
>
> Should this scan skip the filter that is being replaced? When
> route4_change() is called with an existing filter, fold is still linked in
> its bucket chain while route4_set_parms() runs, and f was seeded from it:
>
> net/sched/cls_route.c:route4_change() {
> ...
> if (fold) {
> f->id = fold->id;
> f->iif = fold->iif;
> f->handle = fold->handle;
>
> f->tp = fold->tp;
> f->bkt = fold->bkt;
> new = false;
> }
>
> err = route4_set_parms(net, tp, base, f, handle, head, tb,
> tca[TCA_RATE], new, flags, extack);
> ...
> }
>
> fold is unlinked from b->ht[] only after route4_set_parms() returns
> successfully, so the new scan can walk into fold itself.
>
> Two things seem to follow from that. First, for an in-place change that
> keeps the same to/from, nhandle equals fold->handle and the scan matches
> fold, returning -EEXIST for the very filter the user asked to modify. The
> old code compared fp->handle == f->handle, which is also fold->handle, so
> the self-match itself is pre-existing and not introduced here, but the new
> extack now reports "Handle %x is already in use" for the object being
> modified, which reads as a foreign collision.
>
> Second, does this newly allow a filter to be silently renumbered? The
> 0x7F00 order bits are only folded in for the create path:
>
> net/sched/cls_route.c:route4_set_parms() {
> ...
> if (handle && new) {
> nhandle |= handle & 0x7F00;
> ...
> }
>
> So for something like
>
> tc filter change ... pref 100 handle 0x10101 route from 1 to 1 classid 1:9
>
> nhandle comes out as 0x10001 while fold->handle is 0x10101. to_hash() uses
> only id & 0xFF plus the 0x8000 bit, and from_hash(nhandle >> 16) is
> unchanged, so both handles land in the same b->ht[] chain and fold really is
> visible to the scan. With the old comparison against f->handle the scan
> matched fold and the change was refused; with the comparison against
> nhandle it no longer matches, the change is accepted, and
>
> f->handle = nhandle;
>
> renumbers the filter from 0x10101 to 0x10001. After that, del or replace by
> handle 0x10101 no longer addresses the intended filter. Was that change of
> behaviour intended here?
>
> There is no memory-safety consequence either way: the -EEXIST return happens
> before refcount_inc(&b->filters_ref) and before the f->handle / f->bkt
> assignments.
>
> For what it is worth, both halves appear to be addressed later in the same
> series by "net/sched: cls_route: Fix in-place replace"
FTR: due to the above point, this whole wall of text is pure noise IMHO.
Still there are a few comments referring pre-existing issues that could
deserve some follow-up, please have a look at the full report.
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260907192133.2639067-1-victor%40mojatatu.com
/P
next prev parent reply other threads:[~2026-09-10 9:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 19:21 [PATCH net v2 0/4] net/sched: cls_route: fix bucket retention and handle recomputation Victor Nogueira
2026-09-07 19:21 ` [PATCH net v2 1/4] net/sched: cls_route: free emptied bucket on filter move Victor Nogueira
2026-09-07 19:21 ` [PATCH net v2 2/4] net/sched: cls_route: Reject handle aliasing Victor Nogueira
2026-09-09 10:22 ` netdev-bot+sashiko
2026-09-10 9:27 ` Paolo Abeni [this message]
2026-09-10 12:59 ` Victor Nogueira
2026-09-07 19:21 ` [PATCH net v2 3/4] net/sched: cls_route: Fix in-place replace Victor Nogueira
2026-09-07 19:21 ` [PATCH net v2 4/4] selftests/tc-testing: Add cls_route bucket move and change tests Victor Nogueira
2026-09-10 9:30 ` [PATCH net v2 0/4] net/sched: cls_route: fix bucket retention and handle recomputation 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=fd286e60-73c0-4a6f-8861-7f6cbc197cb0@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vega@nebusec.ai \
--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.