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=1796386384; b=tEbNo6OqmYZOyJ/hhzn5I31IsEtdCj/jbOXKboMawIGHIkjN1z3C2QF6zjNnzfloQTLB OeHCv47PxYKYUqqaKLFlZLN6rDj35eb45seUSkyoUW59JvBCbRCrOgutClcHukxe2rpfG j3+jNbntcycjuK8dO2yuZ9iuFuDf23bDIDPde+/7IglsBzn5OoQ5kI7jX8UQ+aGs9kHOf jWoK7DjqUJCIfn/ziCx2roa+HHbkwcDn0/Tnd6CeOfZ8/8YMsUeQunmRCI45vyW37+Ley 0/NDG4F7X6eWsO61bPbwuvXeMq69OPMlhR2/2dDi0pOlwwuqI2KtO3B2M2J19lzb7Mg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386384; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=DuAwIYJmwWvAK9ZG/cbAP8bpnUWItFfFXqTsFgoiHcs=; b=FCrhTHrHj9FknFCAcYE3yNWd2OMGKMjRBqcV7EKLvaLpCLmQUrUDtXNUA53VAxDXP158 N7ug3yRcFowg1mEeXMquiVduEX4lvp9TvO9idAOyvf6rwzjB+5DjtltV2kxRIwTYwJyVy HX3vkx1BJxUsJbJUbgKmXZuG4o6LsssOKZkTOW3VN73E3DwCTtIhmh2dF0wMUjZSA3K6c tUTW5SmX4YnjQFS26ZRuET/yfVFOPyUPpyV+Jv7kMXMA9zWsf9J3nPLkLPdfWIn4z26CT ohIjpDLvyVFJA29mnYCjp/xH1bog7Nu3PmZjIaUya1WMKXKcOFjoSVymZHsn4Nrr/8w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dEZShWNd; 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 D55AC606A332 for ; Fri, 4 Dec 2026 12:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dEZShWNd Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FD511F00933; Fri, 4 Dec 2026 12:13:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796386384; bh=DuAwIYJmwWvAK9ZG/cbAP8bpnUWItFfFXqTsFgoiHcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dEZShWNdj6xA4cjCX3zkVE8h0GU97cERKkY9KNkHpNZppOjdO5rOZnrSnF3BRe5zM ZdBgpql4RWHxQqxjIRIN6YyEHb+2g6KRsKwG5o/ljWBV0Ztlp1bCwHQxVdj+DE11o9 SorNe9yGJidg+p54KtLxVPAA/WFU0/liY6Om1bTJsQr1ls2FKtfDwyrgaRznme/q0f ei9h6AgMe7lJgBE2EUkElS8i5Wn36sU0Efwd23+hGXG/SBIEQBfb7csirIPbWFSw9X 7iPfTJ7Sb/nm2sCbOANncTTaejjB7VKCl7NbjqGTXPHv3w1p+wkuzkWeCRRYzOpt2p yR3tM6T+Rnasw== From: Sasha Levin To: stable@vger.kernel.org Cc: Eric Dumazet , Justin Iurman , Paolo Abeni , Sasha Levin Subject: [PATCH 6.6.y 2/2] sctp: use skb_set_transport_header_careful() in sctp_v6_err() Date: Fri, 4 Dec 2026 07:13:00 -0500 Message-ID: <20261204121247.2991699-2-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261204121247.2991699-1-sashal@kernel.org> References: <2026120255-scrawny-canola-7dcb@gregkh> <20261204121247.2991699-1-sashal@kernel.org> 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 From: Eric Dumazet [ Upstream commit 13391f1a8c584e7c1addaea3fd47105d92cc724c ] 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. sctp_v6_err() stores @offset, computed by icmpv6_notify() from the extension headers of the packet embedded in an ICMPv6 error. Should the value be truncated, sctp_err_lookup() would read the SCTP header 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, since @offset is relative to the IPv6 header embedded in the ICMPv6 error. No reproducer was written, this is hardening. Use skb_set_transport_header_careful() and ignore the ICMPv6 error if the offset can not be stored. Do this before changing the network header, so that nothing has to be restored on failure. Fixes: 1a37e412a022 ("net: Use 16bits for *_headers fields of struct skbuff") Cc: stable@vger.kernel.org Signed-off-by: Eric Dumazet Link: https://patch.msgid.link/20261113124625.4010206-5-edumazet@kernel.org Reviewed-by: Justin Iurman Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/sctp/ipv6.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index 819930cc4207c..7f0081ec62f66 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -172,8 +172,11 @@ static int sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, /* Fix up skb to look at the embedded net header. */ saveip = skb->network_header; savesctp = skb->transport_header; + if (unlikely(!skb_set_transport_header_careful(skb, offset))) { + __ICMP6_INC_STATS(net, __in6_dev_get(skb->dev), ICMP6_MIB_INERRORS); + return -EINVAL; + } skb_reset_network_header(skb); - skb_set_transport_header(skb, offset); sk = sctp_err_lookup(net, AF_INET6, skb, sctp_hdr(skb), &asoc, &transport); /* Put back, the original pointers. */ skb->network_header = saveip; -- 2.53.0