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=1796382477; b=3RPc9XlZb15w2Ge12hth7fcrPnYqdrdDGarpRYdhLdj/75r2ESBkh846wJiRXxBp5RcD V3dPyQce2yqi0AMS4CEZbNOIWrMiRntwbW3tLHvQP93b3pVLWr/vKjL9qAsMfG5dTYFXg zqYc7P5Ai0Rx/ZKIRrz4TtcRRY4oNB/euOdXMgSX0/QdrRM7Yubj3S7P3m4sZLT0YlNAu ofsMqQujMpsgU39zKnvMGNN9cPqxZfiaYE/Hiwsat0vjDDtiW/iThvOCg2bQRIjp1esii rAeTldxZPcavEe31ikHTeZ30vQD+to+WxHfm51k7+hgnJShUsrM8eTDiacGibfZgxYA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382477; 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=OKLfisar32ry4CEn899z2reeeLANHsCUNizqkmXEHsQ=; b=Wr7obdTbCx+x+coQEqaynRcKtglUz9yhfVTzNJYDdcOPD+LbOnbYzolCRecih4o5qVzx AUx1OVWVOE08FDc/ZCC3NdB7yw/RB+oKK59ATrQ1uxYtN0iAXmAbPAjBug1c4E7o/h964 FYifACjT6VV+8AxK25opGZhe/KrJ/xU6uD0EkCqfCR4gGi3c3rMtTgfXMjFcj9ACwXcW2 aR9RYH1gIarnDZYYWtBtg8W4R5+AQJ/trfKif2Au3wGn5qmk8ibCY4YkIwqaVW1A59wgo i49UhzWoN4LCP6sVmNe5l0AVQUbwffJkE8n1wBC4iPspghTsKZTly22GDY4hFdixO2A== 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=U85ElK5b; 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 2A079606A322; Fri, 4 Dec 2026 11:07:57 +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=U85ElK5b Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BA951F00936; Fri, 4 Dec 2026 11:07:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382477; bh=OKLfisar32ry4CEn899z2reeeLANHsCUNizqkmXEHsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=U85ElK5bxPj77ddOpmo0eTzzQTqBOzmoxEZhEGSGHZR4ILWzFNx0yb5/TUx7IvPOm LbWAWO/DttnkMb9AeK1mHA7yJFVPuEsuBnoc9cTxhS6lLJYb+SqEDxqtRg/co2N1Rz q4npxZ4BzP96H4mLFz+k8qng2BNOlW0nzBBFyoEU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Dumazet , Ido Schimmel , Justin Iurman , Paolo Abeni Subject: [PATCH 6.18 471/703] ipv6: mcast: use skb_set_transport_header_careful() in ipv6_mc_check_exthdrs() Date: Fri, 4 Dec 2026 19:06:10 +0900 Message-ID: <20261204100640.323096946@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet commit 425b1fe50b71628299d33faff28057e7fa4c60c7 upstream. skb->transport_header is a 16-bit offset from skb->head, and U16_MAX is reserved as the "not set" value. skb_set_transport_header() silently truncates an offset that does not fit. ipv6_mc_check_exthdrs() stores the offset returned by ipv6_skip_exthdr(), which depends on the extension headers found in the packet. Should the value be truncated, ipv6_mc_check_icmpv6() and ipv6_mc_check_mld_msg() would then validate and parse the MLD message at the wrong place. Since commit 3744b0964d52 ("ipv6: Implement limits on extension header parsing") a single chain is bounded to IP6_MAX_EXT_HDRS_CNT headers (24576 bytes), so this needs a large skb->data - skb->head on top of it, for instance after several nested decapsulations, each of them possibly pulling its own extension header chain. No reproducer was written, this is hardening. Use skb_set_transport_header_careful() and treat such a packet as broken (-EINVAL). Fixes: 9afd85c9e455 ("net: Export IGMP/MLD message validation code") Cc: stable@vger.kernel.org Signed-off-by: Eric Dumazet Reviewed-by: Ido Schimmel Link: https://patch.msgid.link/20261113124625.4010206-3-edumazet@kernel.org Reviewed-by: Justin Iurman Signed-off-by: Paolo Abeni Signed-off-by: Greg Kroah-Hartman --- net/ipv6/mcast_snoop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/ipv6/mcast_snoop.c +++ b/net/ipv6/mcast_snoop.c @@ -56,7 +56,8 @@ static int ipv6_mc_check_exthdrs(struct if (nexthdr != IPPROTO_ICMPV6) return -ENOMSG; - skb_set_transport_header(skb, offset); + if (!skb_set_transport_header_careful(skb, offset)) + return -EINVAL; return 0; }