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=1796387963; b=di4yodsFzUn/di4Dz6jmToi55ByJrglur3niqT4gFTLmXcQXPXHkdKw5Sw4N3EwHbnXD A34DqA5YRv4o6fGkXZSD8c+wB4d7BBXjud9WuIQ76j5QVjdugLrHyYhJq0glq9WMLaubS q9lIGz3+crErAJExR3VblXm+IThdmzxauZZchRLTzloSilFnX3mHQRBSberanWg4Hcj9D wA2/oUOy3HYUcL7X254OAlMo+7D/vldGr26ykI5i9uuJkX4UprK8/UXri1lAxdSTA/4Dw cB62eHxvRLUH7d7zGVx8QIf/zHPfyjgoyu418QCGmgqz/kRqCixFIJd0ZLmGYtC2CLg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387963; 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=wd+fYroMoHGkq3bAd1j3xrmQMjLYbIkkJxhCCNY5kTI=; b=QfX7rOwp3mIQri6XbzAZ42j09YCM0xI/8Ucg5HQFYBEaQbuFE4Z23B+YAl6U2M5kvWuO N7AzLZWQ9OWjUcI3p1VgUXbzOBCUrTWg9wWVqHsfJecQ6oPldIwJGkHbv2caubRRY6blq xkEJQazW1baZffzRlCv8uQBHuacdVi/RuRYa6F+X0m5kSqpQ6ct1qovghOh3S99monw3Z BqlB1ykf7/Z+Rff+LJSS2YyQomkvllrY/0NmoZaY/G/sypAgj1tSjwT6XbpWzmihPD9US Ak/cf6ZBJaKJ/+meWoBxMMzxYYc45vT2t4d+LraETh+vSmZ6dPLw6G5eNJkCxsdFkbg== 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=fPk0Dw4U; 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 8C042606A32C; Fri, 4 Dec 2026 12:39:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=fPk0Dw4U Received: by smtp.kernel.org (Postfix) with ESMTPSA id 072811F000CE; Fri, 4 Dec 2026 12:39:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387963; bh=wd+fYroMoHGkq3bAd1j3xrmQMjLYbIkkJxhCCNY5kTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fPk0Dw4UJ5dXjaK43pm/YEQvEfJ3Yu1FkrqABnLHwlCTsGJwsWpSdadgjRKJHW1+W /zhxWbI4PsVkK1mJd9f/5vPl4OGmlFp+cV09sBJ5Sg5epaVYfPKYHFYFCH7GCtvmgC inGCKZB9sENbdWr84kT6RLXbv9DL4uBKLNvPYhDE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 0430/1059] ip6mr: clear skb->cb[] in reg_vif_xmit() Date: Fri, 4 Dec 2026 18:59:21 +0900 Message-ID: <20261204100655.462888573@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 238164201431a425e48dfcb8e9a59de63caf175b ] reg_vif_xmit() hands the skb to ip6mr_cache_report() as an MRT6MSG_WHOLEPKT report. skb_realloc_headroom() copies skb->cb[] into the report, which is queued to the mroute socket, where rawv6_recvmsg() reads it as IP6CB. By the time the pim6reg device transmits the packet, skb->cb[] is not IP6CB anymore: qdisc_pkt_len_init() overwrites iif and ra, and any qdisc installed on the device (fq, fq_codel, pie, cake...) or a tc BPF program writing skb->cb[] fills the area holding dst0, srcrt, dst1, lastopt and flags. Since commit dd433671fef3 ("ipv6: validate extension header length before copying to cmsg") these stale offsets can no longer cause out-of-bounds reads, but the mroute socket can still receive bogus IPV6_PKTINFO ifindex and extension header ancillary data. Clear IP6CB before building the report. The skb is freed right after, so nothing else depends on its control block. Fixes: 14fb64e1f449 ("[IPV6] MROUTE: Support PIM-SM (SSM).") Signed-off-by: Eric Dumazet Signed-off-by: Jakub Kicinski [ sashal: Kept the existing rcu_read_lock(); line in reg_vif_xmit() as context and added the memset after it, since upstream had a blank line at that spot. ] Signed-off-by: Sasha Levin --- net/ipv6/ip6mr.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 6c4ddeb48ec60..f5b3b9b8bb7a2 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -625,6 +625,13 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, DEV_STATS_ADD(dev, tx_bytes, skb->len); DEV_STATS_INC(dev, tx_packets); rcu_read_lock(); + + /* skb->cb[] holds qdisc/tc state at this point, not IP6CB. + * ip6mr_cache_report() copies it to the report delivered to + * the mroute socket, where it is read as IP6CB. + */ + memset(IP6CB(skb), 0, sizeof(*IP6CB(skb))); + ip6mr_cache_report(mrt, skb, READ_ONCE(mrt->mroute_reg_vif_num), MRT6MSG_WHOLEPKT); rcu_read_unlock(); -- 2.53.0