From: Fernando Fernandez Mancera <fmancera@suse.de>
To: netdev@vger.kernel.org
Cc: dev@openvswitch.org, aatteka@nicira.com, jesse@nicira.com,
horms@kernel.org, pabeni@redhat.com, kuba@kernel.org,
edumazet@kernel.org, davem@davemloft.net, i.maximets@ovn.org,
echaudro@redhat.com, aconole@redhat.com,
Fernando Fernandez Mancera <fmancera@suse.de>
Subject: [PATCH net-next] net: openvswitch: do not set transport header on later IPv4 fragments
Date: Fri, 2 Oct 2026 21:54:36 +0200 [thread overview]
Message-ID: <20261002195436.8473-1-fmancera@suse.de> (raw)
Currently, check_iphdr() sets the transport header offset for all IPv4
packets, including later fragments that do not contain an L4 header.
As discussed, let's not set the transport header for non-first IPv4
fragments to prevent a future out-of-bounds memory access that can
happen silently because the warning at skb_transport_header_offset()
does not trigger. In addition, defer the transport_len calculation until
after the fragment check.
Link: https://lore.kernel.org/netdev/59d32c37-6151-4649-97bf-bad050dc3f13@ovn.org/
Suggested-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
---
Sashiko: If you notice a similar problem at IPv6 path, we have fixed it
already in net tree, here is submission:
https://lore.kernel.org/netdev/20261002075255.5015-1-fmancera@suse.de/
---
net/openvswitch/actions.c | 4 +++-
net/openvswitch/flow.c | 7 ++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index dc5ff859f114..867c26e14ead 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -322,11 +322,13 @@ static int pop_nsh(struct sk_buff *skb, struct sw_flow_key *key)
static void update_ip_l4_checksum(struct sk_buff *skb, struct iphdr *nh,
__be32 addr, __be32 new_addr)
{
- int transport_len = skb->len - skb_transport_offset(skb);
+ int transport_len;
if (nh->frag_off & htons(IP_OFFSET))
return;
+ transport_len = skb->len - skb_transport_offset(skb);
+
if (nh->protocol == IPPROTO_TCP) {
if (likely(transport_len >= sizeof(struct tcphdr)))
inet_proto_csum_replace4(&tcp_hdr(skb)->check, skb,
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 1c4f3a079044..d549a58180a7 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -189,6 +189,7 @@ static bool arphdr_ok(struct sk_buff *skb)
static int check_iphdr(struct sk_buff *skb)
{
unsigned int nh_ofs = skb_network_offset(skb);
+ const struct iphdr *nh;
unsigned int ip_len;
int err;
@@ -201,7 +202,11 @@ static int check_iphdr(struct sk_buff *skb)
skb->len < nh_ofs + ip_len))
return -EINVAL;
- skb_set_transport_header(skb, nh_ofs + ip_len);
+ nh = ip_hdr(skb);
+
+ if (!(nh->frag_off & htons(IP_OFFSET)))
+ skb_set_transport_header(skb, nh_ofs + ip_len);
+
return 0;
}
--
2.55.0
next reply other threads:[~2026-10-02 19:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 19:54 Fernando Fernandez Mancera [this message]
2026-10-03 20:12 ` [PATCH net-next] net: openvswitch: do not set transport header on later IPv4 fragments netdev-bot+sashiko
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=20261002195436.8473-1-fmancera@suse.de \
--to=fmancera@suse.de \
--cc=aatteka@nicira.com \
--cc=aconole@redhat.com \
--cc=davem@davemloft.net \
--cc=dev@openvswitch.org \
--cc=echaudro@redhat.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=i.maximets@ovn.org \
--cc=jesse@nicira.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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