From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Eric Dumazet <edumazet@kernel.org>,
Ilya Maximets <i.maximets@ovn.org>,
Aaron Conole <aconole@redhat.com>,
Justin Iurman <justin.iurman@gmail.com>,
Paolo Abeni <pabeni@redhat.com>, Sasha Levin <sashal@kernel.org>
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 [thread overview]
Message-ID: <20261204121255.2998344-2-sashal@kernel.org> (raw)
In-Reply-To: <20261204121255.2998344-1-sashal@kernel.org>
From: Eric Dumazet <edumazet@kernel.org>
[ 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 <edumazet@kernel.org>
Reviewed-by: Ilya Maximets <i.maximets@ovn.org>
Reviewed-by: Aaron Conole <aconole@redhat.com>
Link: https://patch.msgid.link/20261113124625.4010206-4-edumazet@kernel.org
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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
prev parent reply other threads:[~2026-12-04 12:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 15:11 FAILED: patch "[PATCH] net: openvswitch: use skb_set_transport_header_careful() in" failed to apply to 6.6-stable tree gregkh
2026-12-04 12:14 ` [PATCH 6.6.y 1/2] batman-adv: reject unrepresentable multicast TVLV offsets Sasha Levin
2026-12-04 12:14 ` Sasha Levin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204121255.2998344-2-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=aconole@redhat.com \
--cc=edumazet@kernel.org \
--cc=i.maximets@ovn.org \
--cc=justin.iurman@gmail.com \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox