]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
vxlan: Fix potential null-ptr-deref in vxlan_gro_prepare_receive().
authorKuniyuki Iwashima <kuniyu@google.com>
Sat, 2 May 2026 03:12:59 +0000 (03:12 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 6 May 2026 00:47:04 +0000 (17:47 -0700)
udp_tunnel_sock_release() could set sk->sk_user_data to NULL
while vxlan_gro_prepare_receive() is running.

Let's check if rcu_dereference_sk_user_data() is NULL after
skb_gro_remcsum_init().

Fixes: 5602c48cf875 ("vxlan: change vxlan to use UDP socket GRO")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260502031401.3557229-7-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/vxlan/vxlan_core.c

index 0ea88232b985119a091097afab1f15608f94df36..abf3ae04d75b97f81f7c4501e41a5e13bb7e389f 100644 (file)
@@ -657,14 +657,18 @@ static struct vxlanhdr *vxlan_gro_prepare_receive(struct sock *sk,
                                                  struct sk_buff *skb,
                                                  struct gro_remcsum *grc)
 {
-       struct sk_buff *p;
        struct vxlanhdr *vh, *vh2;
        unsigned int hlen, off_vx;
-       struct vxlan_sock *vs = rcu_dereference_sk_user_data(sk);
+       struct vxlan_sock *vs;
+       struct sk_buff *p;
        __be32 flags;
 
        skb_gro_remcsum_init(grc);
 
+       vs = rcu_dereference_sk_user_data(sk);
+       if (!vs)
+               return NULL;
+
        off_vx = skb_gro_offset(skb);
        hlen = off_vx + sizeof(*vh);
        vh = skb_gro_header(skb, hlen, off_vx);