Netdev List
 help / color / mirror / Atom feed
From: "Xiang Mei (Microsoft)" <xmei5@asu.edu>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Tom Herbert <tom@herbertland.com>,
	AutonomousCodeSecurity@microsoft.com,
	tgopinath@linux.microsoft.com, kys@microsoft.com,
	"Xiang Mei (Microsoft)" <xmei5@asu.edu>
Subject: [PATCH net] vxlan: add missing NULL check for vxlan_sock in GRO path
Date: Mon,  6 Jul 2026 23:33:44 +0000	[thread overview]
Message-ID: <20260706233344.3334648-1-xmei5@asu.edu> (raw)

vxlan_gro_prepare_receive() reads vs->flags from the vxlan_sock returned
by rcu_dereference_sk_user_data(sk) without a NULL check, unlike the rest
of the driver (e.g. vxlan_rcv() does "if (!vs) goto drop;").

udp_tunnel_sock_release() clears sk_user_data to NULL and waits an RCU
grace period before the socket leaves the hash, so any callback running on
the tunnel socket during teardown must tolerate a NULL sk_user_data. If a
VXLAN device is torn down while GRO runs on its UDP tunnel socket,
sk_user_data can be NULL when a packet carrying VXLAN_HF_RCO arrives,
faulting in NAPI/softirq context.

The GRO path was the only sk_user_data reader on the socket missing this
guard (vxlan_rcv and vxlan_err_lookup already have it; the gro_complete
callbacks do not touch sk_user_data). Add the same NULL check so GRO
flushes instead of dereferencing a NULL socket pointer.

  Oops: general protection fault ... SMP KASAN NOPTI
  KASAN: probably user-memory-access in range [0x2018-0x201f]
  RIP: 0010:vxlan_gro_prepare_receive (drivers/net/vxlan/vxlan_core.c:678)
   vxlan_gro_receive (drivers/net/vxlan/vxlan_core.c:713)
   udp_gro_receive (net/ipv4/udp_offload.c:841)
   ...
   dev_gro_receive (net/core/gro.c:522)
   gro_receive_skb (net/core/gro.c:640)
   tun_napi_poll (drivers/net/tun.c:259)
   ...
  Kernel panic - not syncing: Fatal exception in interrupt

Fixes: 5602c48cf875 ("vxlan: change vxlan to use UDP socket GRO")
Reported-by: AutonomousCodeSecurity@microsoft.com
Signed-off-by: Xiang Mei (Microsoft) <xmei5@asu.edu>
---
 drivers/net/vxlan/vxlan_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index b5b1253ac08b..f2235bae9bfe 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -663,6 +663,9 @@ static struct vxlanhdr *vxlan_gro_prepare_receive(struct sock *sk,
 	struct vxlan_sock *vs = rcu_dereference_sk_user_data(sk);
 	__be32 flags;
 
+	if (!vs)
+		return NULL;
+
 	skb_gro_remcsum_init(grc);
 
 	off_vx = skb_gro_offset(skb);
-- 
2.43.0


             reply	other threads:[~2026-07-06 23:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 23:33 Xiang Mei (Microsoft) [this message]
2026-07-06 23:56 ` [PATCH net] vxlan: add missing NULL check for vxlan_sock in GRO path Kuniyuki Iwashima
2026-07-06 23:59   ` Xiang Mei

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=20260706233344.3334648-1-xmei5@asu.edu \
    --to=xmei5@asu.edu \
    --cc=AutonomousCodeSecurity@microsoft.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tgopinath@linux.microsoft.com \
    --cc=tom@herbertland.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