From: Fernando Fernandez Mancera <fmancera@suse.de>
To: Josef Bacik <josef@toxicpanda.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>
Cc: Juergen Gross <jgross@suse.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Mina Almasry <almasrymina@google.com>,
David Laight <david.laight.linux@gmail.com>,
netdev@vger.kernel.org, xen-devel@lists.xenproject.org
Subject: Re: [PATCH net-next v2 04/15] net: skbuff: fail segmentation when a segment can't be checksummed
Date: Thu, 22 Oct 2026 00:36:26 +0200 [thread overview]
Message-ID: <c8cfc286-df64-49dc-b386-2e89ecc701b2@suse.de> (raw)
In-Reply-To: <20261021-b4-skbuff-bug-on-followups-v2-4-2aa780a03524@toxicpanda.com>
On 10/21/26 3:46 PM, Josef Bacik wrote:
> When the device can't checksum the protocol, skb_segment() computes
> each segment's checksum in software with skb_checksum(). With SG on,
> the segments share the original frags, and a devmem TCP skb keeps its
> whole payload in unreadable frags. The devmem MSG_ZEROCOPY path never
> sets SKBFL_SHARED_FRAG, so the __skb_linearize() fallback is skipped
> too. skb_checksum() then warns and returns 0, and tcp_gso_segment()
> writes a TCP checksum that doesn't cover the payload that goes out.
>
> That's reachable with tx-checksumming off and SG on: sk_setup_caps()
> still gives TCP SG and HW_CSUM, so the dmabuf send is accepted, and
> harmonize_features() strips the checksum features but keeps SG.
>
> Use skb_checksum_full() and fail the segmentation with -EFAULT when it
> can't checksum a segment, as skb_segment() already does when it can't
> copy one.
>
> Found by the Sashiko AI review of an earlier fix for the same path with
> SG off.
>
> Link: https://lore.kernel.org/all/20261009-b4-skb-segment-nosg-unreadable-v1-1-7e2334a55fe8@toxicpanda.com/
> Assisted-by: LLM
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
Reviewed-by: Fernando Fernandez Mancera <fmancera@suse.de>
Thanks!
> net/core/skbuff.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 40d2dd20d47d..88ed2dd99dc0 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -5239,9 +5239,13 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
>
> if (!nskb->remcsum_offload)
> nskb->ip_summed = CHECKSUM_NONE;
> - SKB_GSO_CB(nskb)->csum =
> - skb_checksum(nskb, doffset,
> - nskb->len - doffset, 0);
> + SKB_GSO_CB(nskb)->csum = 0;
> + if (skb_checksum_full(nskb, doffset,
> + nskb->len - doffset,
> + &SKB_GSO_CB(nskb)->csum)) {
> + err = -EFAULT;
> + goto err;
> + }
> SKB_GSO_CB(nskb)->csum_start =
> skb_headroom(nskb) + doffset;
> }
>
next prev parent reply other threads:[~2026-10-21 22:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 13:46 [PATCH net-next v2 00/15] net: skbuff: follow-ups to the BUG_ON() removal Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 01/15] net: skbuff: make skb_copy_and_csum_bits() report unreadable frags Josef Bacik
2026-10-21 21:48 ` Fernando Fernandez Mancera
2026-10-22 8:21 ` Paolo Abeni
2026-10-22 9:54 ` David Laight
2026-10-22 20:07 ` Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 02/15] net: skbuff: add skb_checksum_full() that reports failure Josef Bacik
2026-10-21 22:08 ` Fernando Fernandez Mancera
2026-10-21 13:46 ` [PATCH net-next v2 03/15] net: skbuff: fail checksum validation when the skb can't be checksummed Josef Bacik
2026-10-21 22:28 ` Fernando Fernandez Mancera
2026-10-21 13:46 ` [PATCH net-next v2 04/15] net: skbuff: fail segmentation when a segment " Josef Bacik
2026-10-21 22:36 ` Fernando Fernandez Mancera [this message]
2026-10-21 13:46 ` [PATCH net-next v2 05/15] net: skbuff: fail pskb_trim_rcsum() when it can't checksum the tail Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 06/15] net: skbuff: add skb_crc32c_full() that reports failure Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 07/15] net: skbuff: let skb_zerocopy() copy a short skb without head_frag Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 08/15] net: skbuff: make skb_try_coalesce()'s len unsigned Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 09/15] net: skbuff: check csum_start against len in skb_copy_and_csum_dev() Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 10/15] net: skbuff: reject a negative length in skb_copy_and_csum_bits() Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 11/15] net: skbuff: refuse to segment a nested frag_list Josef Bacik
2026-10-22 1:47 ` Willem de Bruijn
2026-10-22 19:58 ` Josef Bacik
2026-10-23 3:07 ` Willem de Bruijn
2026-10-21 13:46 ` [PATCH net-next v2 12/15] net: test the frag_list layouts skb_segment() refuses Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 13/15] xen-netfront: don't BUG() when skb_copy_bits() fails in bounce_skb() Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 14/15] net/tls: don't BUG() on leftover length in __skb_nsg() Josef Bacik
2026-10-21 13:46 ` [PATCH net-next v2 15/15] net: update comments that still describe the skb BUG_ON()s Josef Bacik
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=c8cfc286-df64-49dc-b386-2e89ecc701b2@suse.de \
--to=fmancera@suse.de \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=david.laight.linux@gmail.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=jgross@suse.com \
--cc=josef@toxicpanda.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sstabellini@kernel.org \
--cc=willemdebruijn.kernel@gmail.com \
--cc=xen-devel@lists.xenproject.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