From: netdev-bot+sashiko@kernel.org
To: edumazet@google.com
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
horms@kernel.org, kuniyu@google.com, idosch@nvidia.com,
andrew+netdev@lunn.ch, netdev@vger.kernel.org,
eric.dumazet@gmail.com
Subject: Re: [PATCH net-next 7/9] vxlan: convert configuration to RCU protection
Date: Mon, 07 Sep 2026 06:11:26 +0000 [thread overview]
Message-ID: <178876148639.219967.11080038703047476901@kernel.org> (raw)
In-Reply-To: <20260903120840.1024153-8-edumazet@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:
Critical: 0 · High: 0 · Medium: 1 · Low: 0
- [Medium] Commit message mischaracterizes a memory-safety fix as
preparatory refactoring, leaving a transient use-after-free in the…
--
vxlan: convert configuration to RCU protection
This converts vxlan->cfg into an __rcu pointer, switches the readers to
rcu_dereference()/rtnl_dereference() and publishes new configurations with
rcu_assign_pointer() while freeing the old one via kfree_rcu(). The TX path
in vxlan_xmit() also grows an rcu_read_lock() section covering all of its
exit paths.
> diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
> index af320173a1e7..c49d55de020f 100644
> --- a/drivers/net/vxlan/vxlan_core.c
> +++ b/drivers/net/vxlan/vxlan_core.c
[ ... ]
> @@ -1704,7 +1704,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
> goto drop;
> }
>
> - cfg = vxlan->cfg;
> + cfg = rcu_dereference(vxlan->cfg);
>
> if (vh->vx_flags & cfg->reserved_bits.vx_flags ||
> vh->vx_vni & cfg->reserved_bits.vx_vni) {
[ ... ]
> @@ -2781,7 +2781,8 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
> u32 nhid = 0;
> u32 flags;
>
> - cfg = vxlan->cfg;
> + rcu_read_lock();
> + cfg = rcu_dereference(vxlan->cfg);
> flags = cfg->flags;
> default_vni = cfg->vni;
> saddr_family = cfg->saddr.sa.sa_family;
[ ... ]
> @@ -4034,9 +4045,10 @@ static void vxlan_config_apply(struct net_device *dev,
> needed_headroom += vxlan_headroom(flags);
> dev->needed_headroom = needed_headroom;
>
> - old_cfg = vxlan->cfg;
> - vxlan->cfg = new_cfg;
> - kfree(old_cfg);
> + old_cfg = rtnl_dereference(vxlan->cfg);
> + rcu_assign_pointer(vxlan->cfg, new_cfg);
> + if (old_cfg)
> + kfree_rcu(old_cfg, rcu);
> }
[Severity: Medium]
Is this change really just preparation, or is it the patch that closes a
use-after-free opened by the preceding patch in the series?
The changelog says:
In order to allow lockless readers in future patches, convert 'vxlan->cfg'
to an RCU protected pointer.
but the lockless readers seem to exist already. At the parent commit
5a2b432e8977 ("vxlan: dynamically allocate struct vxlan_config"),
vxlan_config_apply() does:
old_cfg = vxlan->cfg;
vxlan->cfg = new_cfg;
kfree(old_cfg);
with no grace period, while vxlan_xmit() (softirq) does a plain
cfg = vxlan->cfg; and hands that pointer down to vxlan_xmit_one(),
arp_reduce(), neigh_reduce() and vxlan_xmit_nhid(), and vxlan_rcv() (UDP
encap softirq) does the same before dereferencing cfg->reserved_bits.
vxlan_vs_find_vni(), the vxlan_cleanup() age timer and
vxlan_fill_metadata_dst() read it the same way.
So at that intermediate commit:
CPU0 (RTNL, RTM_NEWLINK changelink)
vxlan_changelink()
vxlan_config_apply()
kfree(old_cfg);
CPU1 (softirq)
vxlan_xmit()
cfg = vxlan->cfg; /* may already be the freed old_cfg */
flags = cfg->flags;
Can an "ip link set ... type vxlan ..." concurrent with traffic free the
config under a live TX or RX reader at that commit?
If so, would it make sense to squash the two patches, or at least say in
this changelog that the previous patch opens that window and this one closes
it, so a partial backport or a bisect does not land on the unsafe commit?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260903120840.1024153-1-edumazet%40google.com
next prev parent reply other threads:[~2026-09-07 6:11 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 12:08 [PATCH net-next 0/9] vxlan: convert configuration to RCU and drop RTNL in vxlan_fill_info() Eric Dumazet
2026-09-03 12:08 ` [PATCH net-next 1/9] vxlan: initialize _md in vxlan_xmit_one() Eric Dumazet
2026-09-05 3:42 ` Kuniyuki Iwashima
2026-09-03 12:08 ` [PATCH net-next 2/9] vxlan: vnifilter: free vxlan_vni_group via RCU in vxlan_vnigroup_uninit() Eric Dumazet
2026-09-05 4:51 ` Kuniyuki Iwashima
2026-09-06 15:40 ` Eric Dumazet
2026-09-07 6:11 ` netdev-bot+sashiko
2026-09-07 6:33 ` Eric Dumazet
2026-09-03 12:08 ` [PATCH net-next 3/9] vxlan: vnifilter: use list_for_each_entry_rcu() in vxlan_vnifilter_dump_dev() Eric Dumazet
2026-09-05 3:56 ` Kuniyuki Iwashima
2026-09-07 6:11 ` netdev-bot+sashiko
2026-09-03 12:08 ` [PATCH net-next 4/9] vxlan: pass vxlan_config pointer to helper functions Eric Dumazet
2026-09-05 4:09 ` Kuniyuki Iwashima
2026-09-03 12:08 ` [PATCH net-next 5/9] vxlan: move VXLAN_F_MDB to struct vxlan_dev flags Eric Dumazet
2026-09-05 4:13 ` Kuniyuki Iwashima
2026-09-07 6:11 ` netdev-bot+sashiko
2026-09-03 12:08 ` [PATCH net-next 6/9] vxlan: dynamically allocate struct vxlan_config Eric Dumazet
2026-09-05 4:29 ` Kuniyuki Iwashima
2026-09-07 6:11 ` netdev-bot+sashiko
2026-09-07 6:39 ` Eric Dumazet
2026-09-03 12:08 ` [PATCH net-next 7/9] vxlan: convert configuration to RCU protection Eric Dumazet
2026-09-05 4:33 ` Kuniyuki Iwashima
2026-09-07 6:11 ` netdev-bot+sashiko [this message]
2026-09-03 12:08 ` [PATCH net-next 8/9] vxlan: remove default_dst and use vxlan_config and lowerdev Eric Dumazet
2026-09-05 4:44 ` Kuniyuki Iwashima
2026-09-07 6:11 ` netdev-bot+sashiko
2026-09-03 12:08 ` [PATCH net-next 9/9] vxlan: no longer rely on RTNL in vxlan_fill_info() Eric Dumazet
2026-09-05 4:45 ` Kuniyuki Iwashima
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=178876148639.219967.11080038703047476901@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox