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 EC6903D7D67; Wed, 20 May 2026 18:26:28 +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=1779301590; cv=none; b=uc91dv7Rr2jX0wcu7+sN0Jq/dKnc0ywn3fEnf22SYVG0z2TAwoHLJmwt7TPi15ojrxkS9bBxGHnpS0hTzYSPlF5rExoNIqIGcaViRNuYy/av6+JpCkpF8pANvGq3ZmImt3uzV4CojhhjkFKN5sxcHQdUosIMAP8N7kacSj8S0vw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779301590; c=relaxed/simple; bh=utJVPP4lNKPgiQPW9N0GgwD/R8egImgv9GVa7DQd87A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iRTqScSNg/E2m6FBZzk3j0W8+YiMeP87rTESSUMddMOIP3PB3cVF8e+D6Mm/BZQ98HBkXJh9Ne6PUNILXgFXbfBwGjKfnz4cyXdMHnu60k/nGYJXQD2EzyTiijEpNEJnfZfJveSId6u4W5h7j71WsDbHoY7OJ/RFk4zWSoQ5+6k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bUhUyIp8; 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="bUhUyIp8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 664201F000E9; Wed, 20 May 2026 18:26:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779301588; bh=1fqSg8Gvs826Fp0Jrj9oJ6O+5AjLu1wcN4BofoyWPkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bUhUyIp81De6aGe0ulVCvwHrWr4wcgMci5Fr/m4pB3HsnJCmAVSWL6kKLB9VySa3i y8r5WpTz+c6h46WxRNmYEuWrD38K+Jy2IybhAK2N2G57RCObtT9ZagIURaPPEg4qfq nMWylh7C0y3oQzkrtc9indFec0hiptZTeaQw/SuM= 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 6.12 571/666] bareudp: fix NULL pointer dereference in bareudp_fill_metadata_dst() Date: Wed, 20 May 2026 18:23:02 +0200 Message-ID: <20260520162123.644918825@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162111.222830634@linuxfoundation.org> References: <20260520162111.222830634@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-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 fa2dd76ba3d9e..8d6b632371f89 100644 --- a/drivers/net/bareudp.c +++ b/drivers/net/bareudp.c @@ -528,6 +528,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, 0, &saddr, &info->key, sport, bareudp->port, info->key.tos, -- 2.53.0