Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, edumazet@kernel.org,
	pabeni@redhat.com, horms@kernel.org,
	Willem de Bruijn <willemb@google.com>,
	stable@vger.kernel.org
Subject: [PATCH net v2 1/2] net: gso: cow head on tcp fraglist fallback to skb_segment
Date: Thu, 19 Nov 2026 23:46:39 -0500	[thread overview]
Message-ID: <20261120044733.222627-2-willemdebruijn.kernel@gmail.com> (raw)
In-Reply-To: <20261120044733.222627-1-willemdebruijn.kernel@gmail.com>

From: Willem de Bruijn <willemb@google.com>

When tcp4_gso_segment() or tcp6_gso_segment() cannot use
skb_segment_list(), they fall back to tcp_gso_segment(), first resetting
th->check to the pseudo-header sum. This writes to skb->head without
unsharing it. If the skb is cloned, e.g., by a packet socket on a bridge
port, the other holders see the rewritten checksum.

Call skb_cow_head(), like skb_segment_list() and the UDP fallback
already unshare the head with skb_unclone() and __skb_linearize().
skb_header_cloned() is equivalent to skb_cloned() here, as GRO does not
set nohdr on the head of fraglist skbs.

Discovered by an AI code review agent. Reproduced on an unmodified
kernel with bridged veth devices and an AF_PACKET socket, and verified
in virtme-ng.

Fixes: 17bd3bd82f9f ("net: gso: fix tcp fraglist segmentation after pull from frag_list")
Cc: stable@vger.kernel.org
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 net/ipv4/tcp_offload.c   | 5 +++++
 net/ipv6/tcpv6_offload.c | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c
index b84fcd07c723..520778c5ca7f 100644
--- a/net/ipv4/tcp_offload.c
+++ b/net/ipv4/tcp_offload.c
@@ -106,11 +106,16 @@ static struct sk_buff *tcp4_gso_segment(struct sk_buff *skb,
 
 	if (skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST) {
 		struct tcphdr *th = tcp_hdr(skb);
+		int err;
 
 		if ((skb_pagelen(skb) - th->doff * 4 == skb_shinfo(skb)->gso_size) &&
 		    !(skb_shinfo(skb)->gso_type & SKB_GSO_DODGY))
 			return __tcp4_gso_segment_list(skb, features);
 
+		err = skb_cow_head(skb, 0);
+		if (err < 0)
+			return ERR_PTR(err);
+
 		skb->ip_summed = CHECKSUM_NONE;
 	}
 
diff --git a/net/ipv6/tcpv6_offload.c b/net/ipv6/tcpv6_offload.c
index eec3778855eb..0914f95f100c 100644
--- a/net/ipv6/tcpv6_offload.c
+++ b/net/ipv6/tcpv6_offload.c
@@ -178,11 +178,16 @@ static struct sk_buff *tcp6_gso_segment(struct sk_buff *skb,
 
 	if (skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST) {
 		struct tcphdr *th = tcp_hdr(skb);
+		int err;
 
 		if ((skb_pagelen(skb) - th->doff * 4 == skb_shinfo(skb)->gso_size) &&
 		    !(skb_shinfo(skb)->gso_type & SKB_GSO_DODGY))
 			return __tcp6_gso_segment_list(skb, features);
 
+		err = skb_cow_head(skb, 0);
+		if (err < 0)
+			return ERR_PTR(err);
+
 		skb->ip_summed = CHECKSUM_NONE;
 	}
 
-- 
2.56.1.750.gf70dc682cf-goog


       reply	other threads:[~2026-11-20  4:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261120044733.222627-1-willemdebruijn.kernel@gmail.com>
2026-11-20  4:46 ` Willem de Bruijn [this message]
2026-11-20  4:46 ` [PATCH net v2 2/2] net: gso: fall back to skb_segment when fraglist cannot satisfy checksum Willem de Bruijn

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=20261120044733.222627-2-willemdebruijn.kernel@gmail.com \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=willemb@google.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