From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793211593; b=EiXyKG6Ia+91L/ls5p9vZ1VLcOQvuxaNMdZ0QYvHxX79xvnE9hvtWjBtWfwBkBjO/zj8 49hqHahzE3s8GZwgYf23/rc6G+fC1oKH/ZmcvGoWVeV/ocK7d3rmu52Q/Dj0BprgTJvmP V6R5AbBsNTxmR6PzllFOZSSoH7l6/S680KmFET8a0WDd3E5yLTgHHc0alNL6bgBlBqNo1 /zcL4mx/WY3wE5Gpj/CzCKqK1UNEXdalYK0eGazapQNfwG27cNokAtuB1M60IPZPKwG2d +t1nkPHnldS8T8AhwWtkOOmZCjwQskBxFnHJLlVXa7WWAvnZcHaC5gFiCHJXXjlDE0g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793211593; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=fJoZiBXFXBymd9huq2t1yPESzY+2h3aTHHbCWmTjpyU=; b=F4mNzODG2btk+wCWnZbzhBx9fuBaMDgdNMnpeGxekUClWULWgWDe3whIB9vx46oBoukk O8zP3BGQHScPHSNWtOdu0WEX60lvwcnVP4cJ2Y2l6zlCwLTZpm4tDe0d9DeAD8uNB0vlp qcYtpzaKa0Zhczwtyl8l1k+nZi1MC033GmwanJK5WexsMxMvIf52KJCNV2XDvdHgpvZlK w3kmT8bTdJN6XK+TYdGY6x6+HC3LWZrD973X+4HI9Y5ZO0sXfeYMlBDoKB7mddK4kRsEE RSahExga0g4nSRKTYOR9ayV0lAISOgZJ3Eyiar7/lR47Bnq7KdL9VBOueyxBLxoq8IQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=t2KTXC8X; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBEDB606A31D; Wed, 28 Oct 2026 18:19:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=t2KTXC8X Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17C6C1F01825; Wed, 28 Oct 2026 18:19:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793211592; bh=fJoZiBXFXBymd9huq2t1yPESzY+2h3aTHHbCWmTjpyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=t2KTXC8X1dxopUkWVjH4qc5kEAUMLe3s4tJsaPJbsuOOEYNRIPBZoNfed3qmCkPmb ywv+FsXZ8u8V3SDDnaHEKrd1k1cHiIS/h8TkszJ2YUywNtQMm0qhkPTae3W+F8NH6N gZuK9imhYXByi+9Ptyf69mt2y6MxHuW0NGpvUCwE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Dumazet , David Ahern , Jakub Kicinski , Harshit Mogalapalli , Sasha Levin Subject: [PATCH 5.15 415/571] ipv6: use RCU in ip6_xmit() Date: Wed, 28 Oct 2026 17:59:22 +0100 Message-ID: <20261028170017.858422473@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170008.009143722@linuxfoundation.org> References: <20261028170008.009143722@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 9085e56501d93af9f2d7bd16f7fcfacdde47b99c ] Use RCU in ip6_xmit() in order to use dst_dev_rcu() to prevent possible UAF. Fixes: 4a6ce2b6f2ec ("net: introduce a new function dst_dev_put()") Signed-off-by: Eric Dumazet Reviewed-by: David Ahern Link: https://patch.msgid.link/20250828195823.3958522-4-edumazet@google.com Signed-off-by: Jakub Kicinski (cherry picked from commit 9085e56501d93af9f2d7bd16f7fcfacdde47b99c) [Harshit: Resolve conflict for missing BIG TCP hop-jumbo context] Signed-off-by: Harshit Mogalapalli Signed-off-by: Sasha Levin --- net/ipv6/ip6_output.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index ab745cda1179b..6db5f25017363 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -257,33 +257,34 @@ bool ip6_autoflowlabel(struct net *net, const struct ipv6_pinfo *np) int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, __u32 mark, struct ipv6_txoptions *opt, int tclass, u32 priority) { - struct net *net = sock_net(sk); const struct ipv6_pinfo *np = inet6_sk(sk); struct in6_addr *first_hop = &fl6->daddr; struct dst_entry *dst = skb_dst(skb); - struct net_device *dev = dst->dev; struct inet6_dev *idev = ip6_dst_idev(dst); + struct net *net = sock_net(sk); unsigned int head_room; + struct net_device *dev; struct ipv6hdr *hdr; u8 proto = fl6->flowi6_proto; int seg_len = skb->len; - int hlimit = -1; + int ret, hlimit = -1; u32 mtu; + rcu_read_lock(); + + dev = dst_dev_rcu(dst); head_room = sizeof(struct ipv6hdr) + LL_RESERVED_SPACE(dev); if (opt) head_room += opt->opt_nflen + opt->opt_flen; if (unlikely(head_room > skb_headroom(skb))) { - /* Make sure idev stays alive */ - rcu_read_lock(); + /* idev stays alive while we hold rcu_read_lock(). */ skb = skb_expand_head(skb, head_room); if (!skb) { IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTDISCARDS); - rcu_read_unlock(); - return -ENOBUFS; + ret = -ENOBUFS; + goto unlock; } - rcu_read_unlock(); } if (opt) { @@ -331,17 +332,21 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, * skb to its handler for processing */ skb = l3mdev_ip6_out((struct sock *)sk, skb); - if (unlikely(!skb)) - return 0; + if (unlikely(!skb)) { + ret = 0; + goto unlock; + } /* hooks should never assume socket lock is held. * we promote our socket to non const */ - return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, - net, (struct sock *)sk, skb, NULL, dev, - dst_output); + ret = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, + net, (struct sock *)sk, skb, NULL, dev, + dst_output); + goto unlock; } + ret = -EMSGSIZE; skb->dev = dev; /* ipv6_local_error() does not require socket lock, * we promote our socket to non const @@ -350,7 +355,9 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, IP6_INC_STATS(net, idev, IPSTATS_MIB_FRAGFAILS); kfree_skb(skb); - return -EMSGSIZE; +unlock: + rcu_read_unlock(); + return ret; } EXPORT_SYMBOL(ip6_xmit); -- 2.53.0