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=1796386311; b=P7wy7CIgmXlOpmMLJFqlhMyeeIHsANXXyaeBgqhyq+PnHl53uAcYfkEywgLp0EQaqQtd EBYvOTj1qDObqEgiNjPRCjIgovTRKrer/KO7rBGxxXZigrnkxaa9Scf1IaHarEXCca/dS cDNianiON5gPUdCC4eIMfw6cmNvKTxoyy91yYpN7/3bRdbLO9msvxf2WEv3FAHd+F1Rq1 lXEuVTQr8qHBdzftPQBmj75NFHOAbAPCx1LWfmAbSKKyvn8yT0NWvP2lTnqI5MgUhcDwm EaRwkGDYOesV2jOdRMESnrrgidKsWENyvAOhYGE39DRS9Fa1ymdnnpGLYi/sUfyNlIA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386311; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=EbpVZGrAwK5sYaEl7wf/zTL4HfOpXW6OBDfcI4DDLB8=; b=2c8M2awMcsJ3/PY8/TfJuyNZbermPfZE5/JzEu4DxulJCd0LLxGIr0a8pDm3GbieVDvT arjC8HVsFul00xI60E9iM5GVHQS2UKEKGh4cD1K1435UFAuLNsuI6dROdAYLhUsAtZPbP 09mDtKewkzP8NIlOjB9SU7MdUObY4kvfl+anU6EnFkZHMMgx7EZhkq/gCJZhD8dQaeItE EgTCVb6CBz3o7L/5XvHQh5tQepCTe7BrX2mHMonUaHXxBTEBFZBgUM4Z/CfP6NJ7r+Gsf dO443N+cWSscfoF8AqvcfYkjUbL3RSmzVCvz0t8p8CFKhq5G2jb4zZ8lJFZXRKGmiiw== 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=DtSPTZxM; 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 13735606A322 for ; Fri, 4 Dec 2026 12:11:51 +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=DtSPTZxM Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE8051F00933; Fri, 4 Dec 2026 12:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796386310; bh=EbpVZGrAwK5sYaEl7wf/zTL4HfOpXW6OBDfcI4DDLB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DtSPTZxMb/8hFaFWpdC4GiLNVwKmWDcKuMb9SypyA+dW/IOqshCilIFk/pTA02rc6 xI0zChIaXeNNfU1A75YiGWZdU8ac4nfnVZXV73OFYDimEogI6UjK3E1+aPypeaUHg2 BEO/tsvkS2uqXwvxYKJviGCnyFkrte9t1cYRBO8MrH57ucd/R7fezmPMFmvA70Mptv bF2dj8oB9MdonzEXnNMjbsI8w69pUSOHSIOGX/1CDREmMpaardA3PA1bdpH3mWm/vY KLZ6VeqhQqAQWCoSlPqy+ehM8ax0ZJA58j48iKhW4fWcm60RGByxsu6GLThthnZTeJ Ex6HwDbqLQ6EQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Eric Dumazet , Hyunwoo Kim , Daniel Borkmann , David Ahern , Ido Schimmel , Aaron Conole , Justin Iurman , Paolo Abeni , Sasha Levin Subject: [PATCH 6.12.y 2/2] ipv6: gro: limit the number of extension headers Date: Fri, 4 Dec 2026 07:11:47 -0500 Message-ID: <20261204121140.2987589-2-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261204121140.2987589-1-sashal@kernel.org> References: <2026120232-ozone-exemplary-0302@gregkh> <20261204121140.2987589-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 050f2adb60434a2b4dee2cf3350269379a32cf72 ] Hyunwoo Kim reported that a long chain of IPv6 extension headers can push the transport header offset of a GRO packet beyond what the 16-bit skb->transport_header can store. The truncated offset is later used by gro_receive_network_flush() to locate the network header of a packet held in the GRO list, leading to an out-of-bounds read. Since commit 3744b0964d52 ("ipv6: Implement limits on extension header parsing"), ip6_protocol_deliver_rcu() drops packets carrying more than IP6_MAX_EXT_HDRS_CNT extension headers, but ipv6_gro_pull_exthdrs() was left unbounded. There is no point trying to aggregate packets that the stack is going to drop anyway if they are locally delivered. Apply the same limit in ipv6_gro_pull_exthdrs(). When the limit is hit, @proto still designates an extension header. Extension header offloads have no gro_receive() callback, so ipv6_gro_receive() takes its existing "goto out" path with flush set, and the packet is given to the normal receive path. Local delivery drops it with SKB_DROP_REASON_IPV6_TOO_MANY_EXTHDRS, while forwarded packets are simply not aggregated. An extension header being at most 2048 bytes, this bounds a chain to 24576 bytes. Note that offsets can still accumulate over nested encapsulations, so the places storing them should be hardened separately. Fixes: 4b0ebbca3e16 ("net: gro: move L3 flush checks to tcp_gro_receive and udp_gro_receive_segment") Cc: stable@vger.kernel.org Reported-by: Hyunwoo Kim Link: https://lore.kernel.org/netdev/avTTQNyvwPP6LtGx@v4bel/ Signed-off-by: Eric Dumazet Cc: Daniel Borkmann Cc: David Ahern Cc: Ido Schimmel Tested-by: Hyunwoo Kim Reviewed-by: Ido Schimmel Reviewed-by: Aaron Conole Link: https://patch.msgid.link/20261113124625.4010206-2-edumazet@kernel.org Reviewed-by: Justin Iurman Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/ipv6/ip6_offload.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c index 1682e1af9fab3..ec59b378ba352 100644 --- a/net/ipv6/ip6_offload.c +++ b/net/ipv6/ip6_offload.c @@ -42,6 +42,7 @@ static int ipv6_gro_pull_exthdrs(struct sk_buff *skb, int off, int proto) { const struct net_offload *ops = NULL; struct ipv6_opt_hdr *opth; + int exthdr_cnt = 0; for (;;) { int len; @@ -54,6 +55,13 @@ static int ipv6_gro_pull_exthdrs(struct sk_buff *skb, int off, int proto) if (!(ops->flags & INET6_PROTO_GSO_EXTHDR)) break; + /* Same limit as ip6_protocol_deliver_rcu(). + * @proto is left pointing to an extension header, + * so that the caller does not aggregate this packet. + */ + if (unlikely(exthdr_cnt++ >= IP6_MAX_EXT_HDRS_CNT)) + break; + opth = skb_gro_header(skb, off + sizeof(*opth), off); if (unlikely(!opth)) break; -- 2.53.0