From: Paolo Abeni <pabeni@redhat.com>
To: Alice Mikityanska <alice.kernel@fastmail.im>,
Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowangio@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
"Simon Horman" <horms@kernel.org>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Jason Xing" <kerneljasonxing@gmail.com>,
"Kuniyuki Iwashima" <kuniyu@google.com>,
"Björn Töpel" <bjorn@kernel.org>,
"Jiayuan Chen" <jiayuan.chen@linux.dev>,
netdev@vger.kernel.org, "Alice Mikityanska" <alice@isovalent.com>
Subject: Re: [PATCH net-next v2 1/2] net: Guard for gso_segs overflow in skb_segment
Date: Tue, 18 Aug 2026 15:38:15 +0200 [thread overview]
Message-ID: <3419e66f-4c67-498b-b42b-30f2ad7bfe6a@redhat.com> (raw)
In-Reply-To: <20260813174613.2920246-2-alice.kernel@fastmail.im>
On 8/13/26 7:46 PM, Alice Mikityanska wrote:
> From: Alice Mikityanska <alice@isovalent.com>
>
> skb_segment calculates 32-bit partial_segs as len / gso_size, and then
> assigns it to the 16-bit gso_segs field. The division might overflow in
> some edge cases where the SKB is BIG TCP (65536 <= len <= 8*65535), and
> gso_size < TCP_MIN_GSO_SIZE = 8. While normally this can't happen due to
> TCP_MIN_GSO_SIZE, an AF_PACKET PACKET_VNET_HDR socket can generate such
> a malformed packet.
>
> Blocking malformed virtio_net packets is implemented in the next patch,
> but this patch clamps partial_segs in skb_segment itself for more
> generic robustness. Should len / gso_size happen to be bigger than
> 65535 in partial GSO, skb_segment will now just produce more than two
> output SKBs, all of which will be valid with gso_segs <= 65535.
Minor nit: I think it would make sense to re-order the patches.
> Signed-off-by: Alice Mikityanska <alice@isovalent.com>
> ---
> net/core/skbuff.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index c82a1472a5ea..439cbfeb02bd 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -4860,7 +4860,7 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
> * doesn't fit into an MSS sized block, so take care of that
> * now.
> */
> - partial_segs = len / mss;
> + partial_segs = min(len / mss, GSO_MAX_SEGS);
Since on top of patch 2/2 the min() should always be a no-op, what about
instead:
if (WARN_ON_ONCE(len/mss > GSO_MAX_SEGS))
return ERR_PTR(-EINVAL);
?
/P
next prev parent reply other threads:[~2026-08-18 13:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 17:46 [PATCH net-next v2 0/2] Guard against gso_segs overflows Alice Mikityanska
2026-08-13 17:46 ` [PATCH net-next v2 1/2] net: Guard for gso_segs overflow in skb_segment Alice Mikityanska
2026-08-18 13:38 ` Paolo Abeni [this message]
2026-08-19 17:18 ` Alice Mikityanska
2026-08-13 17:46 ` [PATCH net-next v2 2/2] virtio-net: Ensure that TCP packets don't overflow gso_segs Alice Mikityanska
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=3419e66f-4c67-498b-b42b-30f2ad7bfe6a@redhat.com \
--to=pabeni@redhat.com \
--cc=alice.kernel@fastmail.im \
--cc=alice@isovalent.com \
--cc=bjorn@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eperezma@redhat.com \
--cc=horms@kernel.org \
--cc=jasowangio@gmail.com \
--cc=jiayuan.chen@linux.dev \
--cc=kerneljasonxing@gmail.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=xuanzhuo@linux.alibaba.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