From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 073643B3896; Sat, 30 May 2026 18:11:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780164699; cv=none; b=PsQWSf7uRwjAoihtaQ8ZKJoNX5CAnZPTaRiv1lh1vf4FjU4Frky19jB7T0UE6ftJij4FSIKP5Ds7wtfdbEuCPiXzqRcPuuplKv9Khe071WadidvzDc6sPZ+otuUtPIFW5ArhvK5ZA6AByGOMcv8IDEw/8xGE358QdLqlCyLxONI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780164699; c=relaxed/simple; bh=SvvpBX7gIR8TAofn56w83ae9LNhCJHip8L1OCcrbMW8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UEi4RQFIBsbdD/r/TzNg86ocnbLvqUXXjYZnvKsrCYHwx0v/sWy7mIr1b7aO1gYrkVFtzM29SxKsNzw4V7Hf0eQc/fannI1pu3AWHYYAxYuiH3scVp6VW/wp6fmeT8/IAx4SVcjBWr6DJCU8dFIeENdMUyBmE1hAiImw9EVsGy4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=CkO4bstN; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="CkO4bstN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 421D01F00893; Sat, 30 May 2026 18:11:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780164697; bh=Kpad6JYjbzUay9MtTXG4hkJyPzQbj3uoxpwJyst/ebg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CkO4bstNOHJtQRUj8qzhvSot2MLYVzy+vZSFJKMBM0xcw18LUOvSGgqDW0dXg2RHq dPXESuOYy48rTEEWgT5Fbud/kSGBojad41QrND0fcgONRaY5uzlr6JDDz/ClK2rZzL 3HjokVTUerAIRIuyGmlrLLVVsE68Ok7Pt5j/KdQc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xiang Mei , Weiming Shi , Kuniyuki Iwashima , Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 633/776] bareudp: fix NULL pointer dereference in bareudp_fill_metadata_dst() Date: Sat, 30 May 2026 18:05:47 +0200 Message-ID: <20260530160256.325207996@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160240.228940103@linuxfoundation.org> References: <20260530160240.228940103@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Weiming Shi [ Upstream commit aa6c6d9ee064aabfede4402fd1283424e649ca19 ] bareudp_fill_metadata_dst() passes bareudp->sock to udp_tunnel6_dst_lookup() in the IPv6 path without a NULL check. The socket is only created in bareudp_open() and NULLed in bareudp_stop(), so calling this function while the device is down triggers a NULL dereference via sock->sk. BUG: kernel NULL pointer dereference, address: 0000000000000018 RIP: 0010:udp_tunnel6_dst_lookup (net/ipv6/ip6_udp_tunnel.c:160) Call Trace: bareudp_fill_metadata_dst (drivers/net/bareudp.c:532) do_execute_actions (net/openvswitch/actions.c:901) ovs_execute_actions (net/openvswitch/actions.c:1589) ovs_packet_cmd_execute (net/openvswitch/datapath.c:700) genl_family_rcv_msg_doit (net/netlink/genetlink.c:1114) genl_rcv_msg (net/netlink/genetlink.c:1209) netlink_rcv_skb (net/netlink/af_netlink.c:2550) Add a NULL check returning -ESHUTDOWN, consistent with the xmit paths in the same driver. Fixes: 571912c69f0e ("net: UDP tunnel encapsulation module for tunnelling different protocols like MPLS, IP, NSH etc.") Reported-by: Xiang Mei Signed-off-by: Weiming Shi Reviewed-by: Kuniyuki Iwashima Reviewed-by: Eric Dumazet Link: https://patch.msgid.link/20260426165350.1663137-2-bestswngs@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/bareudp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c index 4acca20084d36..2b03967c140c1 100644 --- a/drivers/net/bareudp.c +++ b/drivers/net/bareudp.c @@ -513,6 +513,9 @@ static int bareudp_fill_metadata_dst(struct net_device *dev, struct in6_addr saddr; struct socket *sock = rcu_dereference(bareudp->sock); + if (!sock) + return -ESHUTDOWN; + dst = udp_tunnel6_dst_lookup(skb, dev, bareudp->net, sock, &saddr, info, IPPROTO_UDP, use_cache); -- 2.53.0