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 BF42643C05B; Thu, 17 Sep 2026 19:02:40 +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=1789671762; cv=none; b=XAeNPSjyTfRUHZKX7LnPD4W7bgZ6wnYgj1En0v5fGCI0U/Mu+ULY5k1LETebLTC52rgG0Bv7X9EbtLQrz2AJDYf+qipqta/W70QXZRx2Bm4rWUazipVqn3fgMwvDxsDd/WIvnDj7/578zdOOgorfjfnmM8zKHY3OScL0uUtIwxo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789671762; c=relaxed/simple; bh=lg20+kgriIP1W6zBLR4xlwVwQvWJd+N5ajzC7qIMroo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lRPEVYzKefDzQQqV0SKAA/6dM/49vjS6brDMBIPjGVBX6tzuXngcYVGuAe/vB9L5voyXpfOGH278F2fuoP9so85MwFT9pEznFgPeFjLHwe8qvuj9V6qHcWSkFr+NKahLUoO5zYGIADXqCwUkV9uAig9aiq0hyNd7G18KRDN8+jU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1qfL8Uzd; 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="1qfL8Uzd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3AB81F000FF; Thu, 17 Sep 2026 19:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789671760; bh=oetOJt0nHnXzEFDpxp0qw38nfPIU8qzIoqU5ga4SN5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1qfL8UzdQ6kG8GA0vq0BVnF9Et0KwFtgf/TPGRCgOzq+ufXWoyoFcRJlJTZl/YT4x fXvloRCZJwOb8yeqOdgvKWHC+jc/4VLZCxnY32bEdrFfJZ7cvi3RmSpAz56S8Tjv7r KH59HC+iZTtx0YKG+lGzJlLnCCJgxoA9fp4vFXr4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vega , Zhiling Zou , Ido Schimmel , Paolo Abeni , Sasha Levin Subject: [PATCH 6.12 1080/1102] ip: orphan prefetched skbs before multicast forwarding Date: Thu, 17 Sep 2026 16:17:03 +0100 Message-ID: <20260917151607.960207530@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151539.408551884@linuxfoundation.org> References: <20260917151539.408551884@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhiling Zou [ Upstream commit e36ce6e78fe3fc3c071a26750783b7ba081ce10d ] IPv4 and IPv6 input preserve an skb->sk association installed by bpf_sk_assign() so that local delivery can use the selected socket under RCU. Both address families can also prefetch a socket in UDP early demux. In both paths (BPF and UDP early demux) a reference is not guaranteed to be held on the socket. When a multicast packet is not locally deliverable, IPv6 hands the original skb to ip6_mr_input(). IPv4's ip_mr_input() similarly keeps the original skb when local delivery is not needed. Either path can put the skb on an unresolved multicast route queue or forward it after the receive-side RCU section ends. After the prefetched socket is destroyed, a later skb free invokes sock_pfree() and dereferences the stale skb->sk. Orphan the skb before each non-local multicast forwarding path. Local delivery retains the original skb; the existing skb_clone() calls provide multicast forwarding with a socket-free clone. Fixes: cf7fbe660f2d ("bpf: Add socket assign support") Fixes: 08842c43d016 ("udp: no longer touch sk->sk_refcnt in early demux") Cc: stable@vger.kernel.org Reported-by: Vega Signed-off-by: Zhiling Zou Reported-by: Vega Signed-off-by: Zhiling Zou Reviewed-by: Ido Schimmel Link: https://patch.msgid.link/0c52eb3d7532aaf8bccf37e0f7c922143c639735.1786552223.git.zhilinz@nebusec.ai Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ipmr.c | 3 +++ net/ipv6/ip6_input.c | 1 + 2 files changed, 4 insertions(+) --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -2140,6 +2140,9 @@ int ip_mr_input(struct sk_buff *skb) if (IPCB(skb)->flags & IPSKB_FORWARDED) goto dont_forward; + if (!local) + skb_orphan(skb); + mrt = ipmr_rt_fib_lookup(net, skb); if (IS_ERR(mrt)) { kfree_skb(skb); --- a/net/ipv6/ip6_input.c +++ b/net/ipv6/ip6_input.c @@ -566,6 +566,7 @@ int ip6_mc_input(struct sk_buff *skb) if (deliver) { skb2 = skb_clone(skb, GFP_ATOMIC); } else { + skb_orphan(skb); skb2 = skb; skb = NULL; }