From: Florian Westphal <fw@strlen.de>
To: Tamaki Yanagawa <ty@000ty.net>
Cc: netfilter-devel@vger.kernel.org, pablo@netfilter.org,
phil@nwl.cc, coreteam@netfilter.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH nf] netfilter: ipset: restore element before rescanning cidrs on seqcount retry
Date: Sun, 18 Oct 2026 06:55:39 +0200 [thread overview]
Message-ID: <atRROQfgdeGSIU5s@strlen.de> (raw)
In-Reply-To: <20261018035205.1008-1-ty@000ty.net>
Tamaki Yanagawa <ty@000ty.net> wrote:
> mtype_test_cidrs() masks the element under test in place with
> mtype_data_netmask() while walking the cidr array from the most to the
> least specific prefix. Since the walk is restarted on concurrent cidr
> array updates, the IPSET_NET_COUNT == 1 types (hash:net, hash:net,port,
> hash:ip,port,net, hash:net,iface) rescan with an element already masked
> to the widest prefix tried, so a lookup can wrongly match a more specific
> entry at the network base address (e.g. 10.200.3.4 matching 10.0.0.0/29).
> Restore the element before rescanning.
Is this a real world encountered bug or an LLM finding?
> + /* mtype_data_netmask() masks @d in place, undo it before rescanning */
> + *d = orig;
> + goto retry;
Why do we need to do this instead of not masking @d in place to begin
with?
-mtype_test_cidrs(struct ip_set *set, struct mtype_elem *d,
+mtype_test_cidrs(struct ip_set *set, const struct mtype_elem *orig,
+ struct mtype_elem *data, d;
struct hbucket *n;
- struct mtype_elem *data;
retry:
+ d = *orig;
... and fix up all reset calls:
static void
hash_netportnet6_data_reset_elem(struct hash_netportnet6_elem *elem,
- struct hash_netportnet6_elem *orig)
+ const struct hash_netportnet6_elem *orig)
... much cleaner and less error prone, I think.
next prev parent reply other threads:[~2026-10-18 4:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 3:52 Tamaki Yanagawa
2026-10-18 4:55 ` Florian Westphal [this message]
2026-10-18 5:23 ` Tamaki Yanagawa
2026-10-18 11:44 ` Florian Westphal
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=atRROQfgdeGSIU5s@strlen.de \
--to=fw@strlen.de \
--cc=coreteam@netfilter.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
--cc=ty@000ty.net \
/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
all inboxes | Powered by JetHome®