Netdev List
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: "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>,
	Juergen Gross <jgross@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Fernando Fernandez Mancera <fmancera@suse.de>,
	Mina Almasry <almasrymina@google.com>,
	David Laight <david.laight.linux@gmail.com>,
	netdev@vger.kernel.org, xen-devel@lists.xenproject.org,
	Willem de Bruijn <willemb@google.com>
Subject: Re: [PATCH net-next v2 11/15] net: skbuff: refuse to segment a nested frag_list
Date: Thu, 22 Oct 2026 19:58:29 +0000	[thread overview]
Message-ID: <179269910950894.2.12425346173477603662@toxicpanda.com> (raw)
In-Reply-To: <willemdebruijn.kernel.11bad1f39601b@gmail.com>

On Wed, Oct 21, 2026 at 09:47:15PM -0400, Willem de Bruijn wrote:
> This patch became quite a bit more complex because of my request.
> More than I anticipated.
>
> Are you sure this first block is needed?

No, it isn't.  I took it out and ran three KUnit cases with a nested
frag_list under GSO_BY_FRAGS: a linear first member with the nested
bytes counted in its len, the same without them counted, and a paged
first member.  They all still get -EINVAL, from the check in the clone
branch or the one in the frag walk.

> this test for list_skb != NULL is new. Previously this code already
> tested skb_headlen(list_skb) without it. Likely not needed for
> anything new in this patch?

Same answer, the cases above pass without it too.  With every member
checked as it's taken, list_skb can only run out if head_skb->len is
wrong for some other reason, which isn't what this patch is about.

So done this way the patch comes down to the check you suggested in the
frag walk, plus skb_has_frag_list(list_skb) added to the existing
headlen check in the clone branch.  The second one is needed: with only
the frag walk check, the frag_list_nested KUnit case still hits a NULL
pointer dereference in skb_segment(), because the linear member is
cloned, list_skb becomes NULL, and the next pass reads its headlen.

The other option is to go back to the single walk up front from v1.
It's an extra pass over the frag_list, but it's one check in one place.
The difference in behaviour is without SG: there a nested frag_list
whose member doesn't match gso_size goes through the copy path, which
recurses, and a KUnit case for that gets correctly sized segments
today.  The in-walk checks leave that alone and the up front walk would
refuse it.  Nothing in the tree builds a nested frag_list either way.

I lean towards the walk up front for v3 because it's simpler to read.
Would you be ok with that, or do you prefer the two in-walk checks?

net-next is closed, so I'll resend the whole series once it reopens.

Thanks,
Josef

  reply	other threads:[~2026-10-23  0:44 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
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 [this message]
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=179269910950894.2.12425346173477603662@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=almasrymina@google.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=david.laight.linux@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=fmancera@suse.de \
    --cc=horms@kernel.org \
    --cc=jgross@suse.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sstabellini@kernel.org \
    --cc=willemb@google.com \
    --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