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=1796386466; b=a69zTf40hu36EXKsEpxHPVBcfJUfoqp7tZg6Ry4l2RiE9LZJhq5WAuBgzzCeo+5bqLtu T8Mgm6NcUvfxK40b4Zaz/gDw1hbrboB/rSSbBn58wDGM1hFQzJ6Ys0Kd5BQ8s7yPiRFGP 22cV5mH5hpsLWryUJEQqADjm6mB+DUSXPJApdgbOVejXOc1Jb7yspBrsEmGdVUF6Ki2PT q8hFBbU/QXFRAO6UIfiKgQXOXaO3ZRMhOVKqdAeEWnu2GP2/VBe3LlMRPrSoOo4GQKznV fgdexfEd3A2SyvjAH0wJvYKkjylL7NB+kuXAB1/76BkdJoY8u27bxBhNBkrASbCrIWw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386466; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=pByIJkEKfMHBP31/5/pwejDi35PMbnvKrzcs4eIw2To=; b=UnZ8mxpjHfIwtNHIw7SiyqH7iMBfasMtwzsnZxeLVs7iN0cVAgNikLVMB6fYeNsRWvzb PGmzmmxGbflbyNzN+16RgWz6I/O2c7K/MP311C3uj6PQdBdp59fPtugYXeREXR7asY9P1 tv7P29kpT/jIxWe4x37BNInG5pha1G06BDs3grq8qN3ic3NbC/tcVGd+ithsICWvFrxNs MtnQA6gspZqE9zlONeRHETZYcb+i4wsuTrkUFuk0xFRY20XcU3UPegAf2OiSTxJqH8bEA RfaXDO/wV6+4ohCXtCu4rAEVLjFKIuwq6f6pPPbAfBJVTRKzCh4u/053Pe1yNqQbhnQ== 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=NM21nqgm; 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 98BED606A322 for ; Fri, 4 Dec 2026 12:14:26 +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=NM21nqgm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 543A91F00935; Fri, 4 Dec 2026 12:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796386466; bh=pByIJkEKfMHBP31/5/pwejDi35PMbnvKrzcs4eIw2To=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NM21nqgmxL2Y1ewyc31VMGdUmCbZbkZQiwLAIiUmLoUU9GMx8i1nU4nS/J43jT28s qtq/b6+G3losAGNiqDX7QXwwRDlg7KzppOd++NV1bLnnyTmwesxLamfKmmgsycNozU eib28LepBH88CHyr+L48CMS8gJMJRVd/BJU2KpG9MwTitfR+Av87DVzHujrFgoKBjC o5i+4eT2jc1vv252yJrHaM++77Th+bZdtAacb1aeqRJ62Mj3qANBrlAddnT7OsQZNd JSt6DaV5XTIpFp43eBDwfrYbpn7XZyH5lQXFmle55k4jCsHm+rm75I7FdOPV+p0LnV KtaKtBEuu44Sg== From: Sasha Levin To: stable@vger.kernel.org Cc: Eric Dumazet , Ilya Maximets , Aaron Conole , Justin Iurman , Paolo Abeni , Sasha Levin Subject: [PATCH 6.6.y 2/2] net: openvswitch: use skb_set_transport_header_careful() in parse_ipv6hdr() Date: Fri, 4 Dec 2026 07:14:22 -0500 Message-ID: <20261204121255.2998344-2-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261204121255.2998344-1-sashal@kernel.org> References: <2026120228-curdle-uncounted-b8cc@gregkh> <20261204121255.2998344-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 b9b77e2430032c21cc82b7da3a0bc0d8e74e6c26 ] 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. parse_ipv6hdr() stores the payload offset found by ipv6_find_hdr(), which depends on the extension headers found in the packet. Should the value be truncated, key_extract_l3l4() would parse the L4 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. No reproducer was written, this is hardening. Use skb_set_transport_header_careful() and return -EPROTO if the offset can not be stored. As for other ipv6_find_hdr() failures, the caller then sets the transport header to the network header and does not parse L4. While at it, use payload_ofs directly, since nh_ofs + nh_len == payload_ofs. Fixes: 1a37e412a022 ("net: Use 16bits for *_headers fields of struct skbuff") Cc: stable@vger.kernel.org Signed-off-by: Eric Dumazet Reviewed-by: Ilya Maximets Reviewed-by: Aaron Conole Link: https://patch.msgid.link/20261113124625.4010206-4-edumazet@kernel.org Reviewed-by: Justin Iurman Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/openvswitch/flow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c index e4dd04408fd44..a100b1bd55951 100644 --- a/net/openvswitch/flow.c +++ b/net/openvswitch/flow.c @@ -443,7 +443,8 @@ static int parse_ipv6hdr(struct sk_buff *skb, struct sw_flow_key *key) return -EPROTO; nh_len = payload_ofs - nh_ofs; - skb_set_transport_header(skb, nh_ofs + nh_len); + if (unlikely(!skb_set_transport_header_careful(skb, payload_ofs))) + return -EPROTO; key->ip.proto = nexthdr; return nh_len; } -- 2.53.0