From: netdev-bot+sashiko@kernel.org
To: alishmery18@gmail.com
Cc: netdev@vger.kernel.org, idosch@nvidia.com, kuba@kernel.org,
pabeni@redhat.com, davem@davemloft.net, edumazet@kernel.org,
andrew+netdev@lunn.ch, horms@kernel.org, razor@blackwall.org,
roopa@nvidia.com, kuniyu@google.com, petrm@nvidia.com,
aroulin@nvidia.com, shuah@kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v5 5/8] vxlan: leave FDB state and flags unchanged when an update fails
Date: Mon, 16 Nov 2026 05:32:51 +0000 [thread overview]
Message-ID: <179480717141.3136.11745110042567184221@kernel.org> (raw)
In-Reply-To: <20261114221412.255825-6-alishmery18@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 1 (2)
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] On the switchdev-veto exit, vxlan_fdb_update_existing()
(drivers/net/vxlan/vxlan_core.c) still publishes the requested state…
- [Low] The patch fixes a bug userspace can trigger, carries four Fixes:
tags (6681712d67ee, 906dc186e020, 61f46fe8c646, 1274e1cc4226), and is…
Pre-existing issues:
- [Low] When a switchdev driver vetoes the update,
vxlan_fdb_update_existing() restores f->state and f->flags at…
- [Low] The comment the patch adds in vxlan_fdb_update_existing() (lines
1038-1042) says the ageing timer reads f->state and f->flags without…
--
vxlan: leave FDB state and flags unchanged when an update fails
This commit moves the state and flags write in vxlan_fdb_update_existing()
so that it comes after the nexthop update, the non-unicast replace check
and the NLM_F_APPEND allocation. A request refused at any of those steps
no longer changes the entry. When a switchdev driver vetoes the
notification, the saved state and flags are written back.
> The patch "vxlan: vnifilter: account the default FDB entry to memcg"
> later in this series makes the NLM_F_APPEND allocation fail routinely
> at a memory cgroup limit, on the path that changes a vnifilter VNI's
> default entry; this is ordered before it so that failure leaves the
> entry as it was. Like the rest of the series it targets net-next.
[Severity: Low]
This isn't a bug, but could this patch go to net instead of net-next?
It carries four Fixes: tags. The bug it fixes is in released kernels and
userspace can trigger it: a refused RTM_NEWNEIGH, such as an NLM_F_REPLACE
of the all-zeros entry with NUD_REACHABLE that gets -EOPNOTSUPP, leaves the
entry dynamic, and vxlan_cleanup() then ages it out.
The dependency on the memcg patch only goes one way. The earlier patches in
the series don't touch drivers/net/vxlan/vxlan_core.c, so this one looks
like it applies on its own. The rest of the series could still follow in
net-next.
The series notes that net-next was suggested for the related "vxlan:
vnifilter: roll back a VNI add that fails" fix, so this may be the
maintainers' call.
> diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
> index d11028b374721..2303d652d3968 100644
> --- a/drivers/net/vxlan/vxlan_core.c
> +++ b/drivers/net/vxlan/vxlan_core.c
[ ... ]
> @@ -1048,6 +1035,23 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan,
> notify |= rc;
> }
>
> + /* Do not allow an externally learned entry to take over an entry added
> + * by the user. The state and flags are written only after the steps
> + * above that can fail, so that a request they refuse never changes
> + * them, not even briefly: the ageing timer reads them without the lock.
> + */
> + if (!(fdb_flags & NTF_EXT_LEARNED) ||
> + !(f->flags & NTF_VXLAN_ADDED_BY_USER)) {
> + if (f->state != state) {
> + f->state = state;
> + notify = 1;
> + }
> + if (f->flags != fdb_flags) {
> + f->flags = fdb_flags;
> + notify = 1;
> + }
> + }
[Severity: High]
Can a request that a switchdev driver vetoes still get a permanent entry
aged out? On the veto path, the new state and flags are still written into
the live entry before vxlan_fdb_notify(). They only get their old values
back at err_restore.
vxlan_cleanup() reads them without hash_lock. Once it decides the entry has
expired, the only thing it rechecks under the lock is hlist_unhashed():
drivers/net/vxlan/vxlan_core.c:vxlan_cleanup() {
...
if (f->state & (NUD_PERMANENT | NUD_NOARP))
continue;
if (f->flags & NTF_EXT_LEARNED)
continue;
...
timeout = READ_ONCE(f->updated) + cfg->age_interval * HZ;
if (time_before_eq(timeout, jiffies)) {
spin_lock(&vxlan->hash_lock);
if (!hlist_unhashed(&f->fdb_node)) {
...
f->state = NUD_STALE;
vxlan_fdb_destroy(vxlan, f, true, true);
}
...
}
Take a NUD_PERMANENT entry whose f->updated is older than age_interval, and
a request that makes it dynamic and then gets vetoed:
CPU1 (hash_lock held)
vxlan_fdb_update_existing()
f->state = state;
CPU2
vxlan_cleanup()
sees f->state without NUD_PERMANENT
sees the old, expired f->updated
spin_lock(&vxlan->hash_lock) waits
WRITE_ONCE(f->updated, jiffies);
vxlan_fdb_notify() is vetoed
f->state = old_state;
hash_lock released
hlist_unhashed() is false
vxlan_fdb_destroy()
On x86 the window is the gap between the f->state store and
WRITE_ONCE(f->updated). On arm64 or powerpc nothing orders the plain
f->state load against READ_ONCE(f->updated), so the window could span the
whole notifier call.
Flags have the same window. A vetoed user request on an NTF_EXT_LEARNED
entry clears NTF_EXT_LEARNED for a moment.
An in-tree driver can veto. mlxsw_sp_switchdev_event() returns NOTIFY_BAD
in two cases:
- mlxsw_sp_switchdev_vxlan_work_prepare() rejects the remote, for example
an NLM_F_REPLACE that changes the remote port and the state together.
- Its GFP_ATOMIC allocation fails.
The commit message says:
The switchdev notification reports the new state, so it still
follows the write
Is that accurate for the state? vxlan_fdb_switchdev_notifier_info() takes
only this field from the entry:
fdb_info->added_by_user = fdb->flags & NTF_VXLAN_ADDED_BY_USER;
It never reads fdb->state. Only the rtnl part, __vxlan_fdb_notify(), needs
the new state, and it runs after the switchdev call.
Would either of these work instead?
- Make the switchdev call before the new state is written.
- Recheck state, flags, nh and updated under hash_lock in vxlan_cleanup().
The second would also close the race with a successful update that the
commit message leaves open. Nothing later in the series touches this code
or vxlan_cleanup().
> +
> if (ndm_flags & NTF_USE)
> WRITE_ONCE(f->updated, jiffies);
[Severity: Low]
This isn't a bug introduced by this patch, but the new comment says the
ageing timer reads f->state and f->flags without the lock, and the stores
above are plain.
f->updated is written with WRITE_ONCE() here, and vxlan_cleanup() reads it
with READ_ONCE(). f->state and f->flags are read there with plain loads.
Should f->state and f->flags also use WRITE_ONCE() and READ_ONCE()? As
written, KCSAN would report these accesses as data races, and the patch
adds two more plain stores at err_restore.
> @@ -1066,13 +1070,17 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan,
>
> err_notify:
> if (nhid)
> - return err;
> + goto err_restore;
> if ((flags & NLM_F_REPLACE) && rc)
> *rd = oldrd;
> else if ((flags & NLM_F_APPEND) && rc) {
> list_del_rcu(&rd->list);
> call_rcu(&rd->rcu, vxlan_dst_free);
> }
> +err_restore:
> + /* The notification was vetoed: put back the state and flags. */
> + f->state = old_state;
> + f->flags = old_flags;
[Severity: Low]
This is a pre-existing issue, but f->updated isn't restored here. It is set
to jiffies before vxlan_fdb_notify(), both in the notify block and when
NTF_USE is set.
So a vetoed request still refreshes the ageing timestamp. Userspace can see
that through NDA_CACHEINFO, and a dynamic entry gets up to one more
age_interval.
Should f->updated also be put back on a veto? The old code did the same
thing, and the commit title only covers state and flags.
Separately, the nhid branch of err_notify looks unreachable.
first_remote_rtnl() returns NULL when f->nh is set, so vxlan_fdb_notify()
never makes the switchdev call for nexthop entries.
> return err;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261114221412.255825-1-alishmery18%40gmail.com
next prev parent reply other threads:[~2026-11-16 5:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 22:14 [PATCH net-next v5 0/8] vxlan: vnifilter: bound a single request and account per-VNI memory Ali Firas
2026-11-14 22:14 ` [PATCH net-next v5 1/8] vxlan: vnifilter: reject VNIs outside the 24-bit space Ali Firas
2026-11-14 22:14 ` [PATCH net-next v5 2/8] vxlan: vnifilter: clamp the dumped VNI range to the request limit Ali Firas
2026-11-14 22:14 ` [PATCH net-next v5 3/8] vxlan: vnifilter: bound the number of VNIs one request may touch Ali Firas
2026-11-16 5:32 ` netdev-bot+sashiko
2026-11-14 22:14 ` [PATCH net-next v5 4/8] vxlan: vnifilter: account per-VNI memory to memcg Ali Firas
2026-11-14 22:14 ` [PATCH net-next v5 5/8] vxlan: leave FDB state and flags unchanged when an update fails Ali Firas
2026-11-16 5:32 ` netdev-bot+sashiko [this message]
2026-11-14 22:14 ` [PATCH net-next v5 6/8] vxlan: vnifilter: roll back a VNI add that fails Ali Firas
2026-11-14 22:14 ` [PATCH net-next v5 7/8] vxlan: vnifilter: account the default FDB entry to memcg Ali Firas
2026-11-14 22:14 ` [PATCH net-next v5 8/8] selftests: net: test the vxlan vnifilter request limit and dump replay Ali Firas
2026-11-16 5:32 ` netdev-bot+sashiko
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=179480717141.3136.11745110042567184221@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=alishmery18@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=aroulin@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=razor@blackwall.org \
--cc=roopa@nvidia.com \
--cc=shuah@kernel.org \
/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