🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14674

Re: [PATCH net] vxlan: annotate lockless accesses to rdst->remote_ifindex

#14674
From: netdev-bot+sashiko
Date: Wed, 11 Nov 2026 19:24
88 lines
11038 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 0

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] Rolling back a failed FDB replace still writes
  rdst->remote_ifindex with a plain store, so the patch misses one of…

--

vxlan: annotate lockless accesses to rdst->remote_ifindex

The patch adds READ_ONCE() to the lockless RCU readers of
rdst->remote_ifindex in vxlan_fdb_info(),
vxlan_fdb_switchdev_notifier_info(), vxlan_snoop() and vxlan_xmit_one().
It also changes the in-place update in vxlan_fdb_replace() to use
WRITE_ONCE().

> diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
> index d11028b374721..13bfb1bb11b7b 100644
> --- a/drivers/net/vxlan/vxlan_core.c
> +++ b/drivers/net/vxlan/vxlan_core.c

[ ... ]

> @@ -569,7 +572,7 @@ static int vxlan_fdb_replace(struct vxlan_fdb *f,
>  	rd->remote_ip = *ip;
>  	rd->remote_port = port;
>  	rd->remote_vni = vni;
> -	rd->remote_ifindex = ifindex;
> +	WRITE_ONCE(rd->remote_ifindex, ifindex);
>  	rd->offloaded = false;
>  	return 1;
>  }

[Severity: High]
This annotates the forward write in vxlan_fdb_replace(). Is the rollback
of the same write in vxlan_fdb_update_existing() still a plain store?

drivers/net/vxlan/vxlan_core.c:vxlan_fdb_update_existing() {
    ...
		err = vxlan_fdb_notify(vxlan, f, rd, RTM_NEWNEIGH,
				       swdev_notify, extack);
		if (err)
			goto err_notify;
    ...
err_notify:
	if (nhid)
		return err;
	if ((flags & NLM_F_REPLACE) && rc)
		*rd = oldrd;
    ...
}

When vxlan_fdb_notify() fails after vxlan_fdb_replace() has run, the
struct copy rewrites rd->remote_ifindex on an rdst that is still linked
on f->remotes. Only vxlan->hash_lock is held. vxlan_xmit_one(),
vxlan_snoop() and the RCU dump paths can be reading the field with the
new READ_ONCE() at the same time.

This path can be reached in tree. mlxsw_sp_switchdev_vxlan_work_prepare()
returns -EOPNOTSUPP for a non-zero remote_ifindex ("Local interface is
not supported"), a non-default port or VNI, or a multicast destination.
It also fails if its GFP_ATOMIC allocation fails. The result is
NOTIFY_BAD, and vxlan_fdb_notify() then returns an error. So a
"bridge fdb replace ... via <dev>" on an mlxsw-offloaded VXLAN goes
through WRITE_ONCE() and then a plain-store restore while traffic is
flowing.

Would it make sense to restore the fields one at a time in err_notify,
using WRITE_ONCE(rd->remote_ifindex, oldrd.remote_ifindex)?

A related point about the same struct copy: it also copies the old
rd->dst_cache back, including reset_ts from before the
dst_cache_reset() in vxlan_fdb_replace(). Could a dst that TX cached
for the rejected destination during that window count as valid again
once the old destination is restored? Calling dst_cache_reset() again
in the rollback, instead of copying dst_cache back, would avoid that.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261110072208.3273638-1-edumazet%40kernel.org
Technical Details
Message-ID: <179442509959.2199510.3903700917435793719@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361251-linux-kernel-netdev=dewy.ru
References: <20261110072208.3273638-1-edumazet@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361251-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] vxlan: annotate lockless accesses to rdst->remote_ifindex
Date: Wed, 11 Nov 2026 19:24:59 +0000
Organization: Usenet Network
Message-ID: <179442509959.2199510.3903700917435793719@kernel.org>
References: <20261110072208.3273638-1-edumazet@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="923471"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:lZDfwv/qCactOhyPvEYNOPz0WoE= sha256:YDRojDtfDJQOaSUikuzKxDP+r6jIYpzlfldEAqZ0Kqg=
	sha1:wBPCBFzCdyCdtpgIE7eiYJi1i10= sha256:zL/oH8DvOCjnRqS2fVhVSDpfOGW9JxHRH3kmEef8o5g=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id CB2AC113FAA; Wed, 11 Nov 2026 22:36:09 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id KTJzpLoIAT1l;
	Wed, 11 Nov 2026 22:36:04 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-361251-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id DC591113FA7; Wed, 11 Nov 2026 22:35:54 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 1EF35684DE8; Wed, 11 Nov 2026 19:28:54 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794425101;
	b=yWK1krMUMVwkilGTQesWB506XQPWgnHvw4A4AIRcYLEMG2EV4ycuX5BlA8wHNP1yyTsw
	 O9Ypf0TxKusbEH72asdB0FJB5CvGmlXUpGnx4HoZCgdE2YifVwBghjdmNy7z/sj5h70rh
	 ZVt+qxtTNyGlFPx2K4GASkEuAIMPAYvitgx0sBnsvrRGtfe8Gn1+NcdfChxlncauY4UJJ
	 cTp6EuKT0MX5TSxMp8Jw0XVwOanlIO2jAdkOj5ZwzfaX9myskJfQkrFj/fe/XwvdCBYbh
	 c4UcAO8Xjf7KHicwkeAKiiMiKjuP2qdAzqnHesqz3o8930aUA6XijIiwBT+3hLaPHDQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794425101;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=6UbhasV7MgH1+H5s5GgeNx3/kPkJyVxkDdLk3Ej1BsM=;
	b=Zs2GUSiSwDE/VBS+MeAVtf0XUTnFszRGxe+f56NwlZfpxBdnIPWMKs5v5UAFxe1RDq6Z
	 NRjqbBFrgnoHQSHKFNkbh9ROnFjChW5GG6WtfNWKl3iAinwtZt03vnMwLpCxNcfXaQGUi
	 AMBn4zwEOQXd7Zt3OBhSsoIOWvRSJgPWRjnWx4EWAnJp3YwEKXErhrMwhwZrRF8wTJCUC
	 R0nakc+L2Sbn/u4Y/wU37/xJnHJY8N/x0Gz9zyymsALaAodYct0ShyLib5NhvahDjMofD
	 UqTyHOGJRe1Iia3pMmBgCVXUEdJAjP3oVY2YSF6UPC+hoA2v5tL7ZvJ9ZrP5iXbaYAw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KNi+2f2y;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D90B7606A883;
	Wed, 11 Nov 2026 19:25:01 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KNi+2f2y
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794425101;
	b=Y9psRFO8tqWWXTX43g0nHZM69nxnh6/awiaxBA1XqQ2X5NAo4dReVvEwA1Ix1MuaE9Zw
	 uaOLeA739b4JSnPMpF4GKrBOJvRNhTwuy905+lVF213ki5U9A6iBImbzG2EImUNWfNsKO
	 1Kswiug8YO6elgufyScABRf+Kisj5TaEHXNyjzX7IoBB9xkpmG72jLVM8YdGLUu0Z/mgi
	 n0xoAVrOftY1xlqrooxo1/hEcNb2YYC3x8YlFUQWKVH+tZIgRl4C5DwCiMXiiy1ZIsYQ4
	 jg5D0E+z2Cv4094p4lfaG8lqpv50lexyjpAyPWUTuNN5G6vlAJSwjl3lVRv9cs0RohA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794425101;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=6UbhasV7MgH1+H5s5GgeNx3/kPkJyVxkDdLk3Ej1BsM=;
	b=NpD+1g3vmeZNPj8iGZoPgeEYH8gyc70qTldU2dJfxTVip+J6lhdpCLEa9GNGaraOGGyN
	 88inqexOULyHCGeUlzfRMxRm1gi2V2EL8UfmD3zl7JoiJrhNcb5XIsXIfPDChNqRhzUvQ
	 NxI/M4T/+WqdSONLCWjPtW+e1H0/UY5ue8iOUmjhUzNI5cpWftfqRWfGT+wRBr5zqF94D
	 x8nbBUkln1DovQ042IeNQZK4L4YU+oRkRYu8JWGXLrPzOXZ7RhErMLC4j9mPzzsxMgO6A
	 TOuEHod+/179JDlc50XVHQWCeP001mNj7W/N9d+FZTDWVepboKfs2hBN1P43Ziijw9w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KNi+2f2y;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03C98606A339
	for <netdev@vger.kernel.org>; Wed, 11 Nov 2026 19:25:00 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44DE41F00A05;
	Wed, 11 Nov 2026 19:25:00 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794425100;
	bh=6UbhasV7MgH1+H5s5GgeNx3/kPkJyVxkDdLk3Ej1BsM=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=KNi+2f2yFKYqGyBVbRa8dDNSlF+mNLnEu0V3sgEqDPqx7YajwUtLosidL875F2P4F
	 FsAWItV/B9VBqP7v1iB7AcE88UHAjzOFv6ytgodU/qfbJire2P3mO78w64jBe3jiqv
	 E4Yj0WD8L85NcgSpgQv4F+FQJUPnOP6c6/2hOULk762eiB7hWniNE3sTR85oGFiW8l
	 cQ/88+4B/V0gZ/yaEDEkrTNVali8qUiYV65xzwDKTNHbCEwFIT5igxqrK+v/5ZMP+k
	 Y9EQX2WGcNoiUbssvxupODAblpI5NdAH6gMXVcW89vVjizDkL13jGywGOl/c5Gl9g7
	 /R9ScsGz+Jn3Q==
X-Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
 netdev@vger.kernel.org
X-In-Reply-To: <20261110072208.3273638-1-edumazet@kernel.org>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list