BPF List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: tavip@google.com
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, willemb@google.com,
	horms@kernel.org, andrew+netdev@lunn.ch, ncardwell@google.com,
	kuniyu@google.com, dsahern@kernel.org, idosch@nvidia.com,
	john.fastabend@gmail.com, jakub@cloudflare.com,
	jiayuan.chen@linux.dev, sd@queasysnail.net, shuah@kernel.org,
	almasrymina@google.com, sdf@fomichev.me, kaiyuanz@google.com,
	ilias.apalodimas@linaro.org, hawk@kernel.org,
	mcroce@microsoft.com, herbert@gondor.apana.org.au,
	ecree.xilinx@gmail.com, bpf@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net 03/10] inet: frag: reject fragments with mixed readability in reassembly
Date: Fri, 04 Dec 2026 22:07:49 +0000	[thread overview]
Message-ID: <179642206934.3146.322907419982921858@kernel.org> (raw)
In-Reply-To: <26a527b0c0dc802b38a8a25081a101b4e3263841.1796329894.git.tavip@google.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch propagates head->unreadable to the wrapper skb that
  inet_frag_reasm_prepare() (net/ipv4/inet_fragment.c) allocates when…
- [Low] The commit message says the patch will "reject a fragment" when
  its readability differs from the queue's.
- [Low] The commit message gives two triggers for mixed readability.

--

inet: frag: reject fragments with mixed readability in reassembly

This patch makes inet_frag_queue_insert() reject a fragment when its
readability differs from the fragments already queued, in the same way
as the existing secpath check. It also copies head->unreadable to the
wrapper skb that inet_frag_reasm_prepare() allocates when the first
fragment already carries a frag_list.

> Mixing readable and unreadable fragments in the same
> reassembly queue (for example, when fragments split across a devmem queue
> and a normal queue, or when a size-threshold spill places only larger
> fragments in unreadable netmem) produces a mixed-readability reassembled
> skb that fails on delivery with -EFAULT or -ENODEV.

[Severity: Low]

Can the size-threshold example happen in this tree?

Both devmem and io_uring zcrx bind through
netif_mp_open_rxq()->__netif_mp_open_rxq(), and that function refuses a
non-zero header-data-split threshold:

net/core/netdev_rx_queue.c:__netif_mp_open_rxq() {
    ...
	if (dev->cfg->hds_thresh) {
		NL_SET_ERR_MSG(extack, "hds-thresh is not zero");
		return -EINVAL;
	}
    ...
}

With hds_thresh == 0, the payload of every packet on a memory provider
queue goes to net_iov frags. Drivers also cannot copybreak net_iov
memory. So a threshold-based mix within one queue does not look possible
upstream, and only the cross-queue case seems to apply to current
kernels.

That example may come from the per-socket devmem RX work mentioned
later in the message. Could it be dropped or qualified, so stable
backporters get an accurate picture of the exposure?

> diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
> index f330d0a398233..caf07cf1a411c 100644
> --- a/net/ipv4/inet_fragment.c
> +++ b/net/ipv4/inet_fragment.c
> @@ -444,9 +444,15 @@ int inet_frag_queue_insert(struct inet_frag_queue *q, struct sk_buff *skb,
>  {
>  	struct sk_buff *last = q->fragments_tail;
>  
> -	/* The reassembled skb keeps the first fragment's secpath. */
> -	if (last && !secpath_equal(last, skb))
> -		return IPFRAG_MIXED_SECPATH;
> +	/* The reassembled skb keeps the first fragment's secpath and
> +	 * readability state.
> +	 */
> +	if (last) {
> +		if (!secpath_equal(last, skb))
> +			return IPFRAG_MIXED_SECPATH;
> +		if (skb_frags_readable(last) != skb_frags_readable(skb))
> +			return IPFRAG_MIXED_READABILITY;

[Severity: Low]

The commit message says this will "reject a fragment". Don't the
callers end up discarding the whole datagram instead?

In ip_frag_queue(), every error except IPFRAG_DUP falls through to
discard_qp:

net/ipv4/ip_fragment.c:ip_frag_queue() {
    ...
insert_error:
	if (err == IPFRAG_DUP) {
		SKB_DR_SET(reason, DUP_FRAG);
		err = -EINVAL;
		goto err;
	}
	if (err == IPFRAG_OVERLAP)
		__IP_INC_STATS(net, IPSTATS_MIB_REASM_OVERLAPS);
	err = -EINVAL;
discard_qp:
	inet_frag_kill(&qp->q, refs);
	__IP_INC_STATS(net, IPSTATS_MIB_REASMFAILS);
    ...
}

ip6_frag_queue() and nf_ct_frag6_queue() also treat any non-DUP error
as a failure.

So a single fragment that lands on a queue with different readability
kills the queue and drops every fragment already queued. One example
is a non-first fragment that RSS hashes away from the devmem queue.

Dropping the datagram matches IPFRAG_MIXED_SECPATH. However, the skb is
freed with the default NOT_SPECIFIED drop reason, and there is no
dedicated counter like IPSTATS_MIB_REASM_OVERLAPS. Only REASMFAILS goes
up.

Would a specific drop reason or counter be worth adding? Could the
commit message also say that the whole datagram is discarded?

> +	}
>  
>  	if (skb->truesize > INET_FRAG_MAX_TRUESIZE - q->truesize)
>  		return IPFRAG_TOOBIG;
> @@ -639,6 +645,7 @@ void *inet_frag_reasm_prepare(struct inet_frag_queue *q, struct sk_buff *skb,
>  		head->truesize += clone->truesize;
>  		clone->csum = 0;
>  		clone->ip_summed = head->ip_summed;
> +		clone->unreadable = head->unreadable;
>  		add_frag_mem_limit(q->fqdir, clone->truesize);
>  		skb_shinfo(head)->frag_list = clone;
>  		nextp = &clone->next;

[Severity: Medium]

With this propagation, can the devmem receive path actually deliver
the nested layout built here? After this branch the chain is:

  head->frag_list  = clone
  clone->frag_list = original frag_list of the first fragment
  clone->next      = later fragments (nextp = &clone->next is used by
                     inet_frag_reasm_finish())

tcp_recvmsg_dmabuf() moves to the next skb with:

net/ipv4/tcp.c:tcp_recvmsg_dmabuf() {
    ...
		skb = skb_shinfo(skb)->frag_list ?: skb->next;
    ...
}

>From the clone, it goes down into clone->frag_list and follows that
chain to NULL. It never comes back to clone->next.

The bytes of the later fragments are never reached, and remaining_len
stays non-zero. The result is -EFAULT, or a short read followed by
-EFAULT on the next call.

Before this patch, the readable clone failed earlier with -ENODEV:

	if (skb_frags_readable(skb)) {
		err = -ENODEV;
		goto out;
	}

So this input is not a regression. But it also doesn't seem to deliver
the "uniformly unreadable fragments to reassemble" case described in
the commit message.

The readable path, __skb_datagram_iter() via skb_walk_frags(), handles
nested frag_lists, so only the devmem consumer disagrees with this
layout. The accompanying KUnit test only checks the readability flag on
the wrapper, not delivery.

Hitting this needs an unreadable first fragment that already has a
frag_list. One example is the inner first fragment of a tunnelled
datagram that was reassembled itself, so it may be uncommon.

Should tcp_recvmsg_dmabuf() walk nested frag_lists? Or should
reassembly avoid building this layout when the head is unreadable?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1796329894.git.tavip%40google.com

  parent reply	other threads:[~2026-12-04 22:07 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 21:09 [PATCH net 00/10] net: fix unreadable net_iov skb handling across networking paths Octavian Purdila
2026-12-03 21:09 ` [PATCH net 01/10] net: gro: free skb on napi_frags_skb() header pull failure Octavian Purdila
2026-12-04 18:31   ` Mina Almasry
2026-12-03 21:09 ` [PATCH net 02/10] net: gro: reset unreadable and pp_recycle in napi_reuse_skb Octavian Purdila
2026-12-04 18:32   ` Mina Almasry
2026-12-04 21:07     ` Octavian Purdila
2026-12-04 21:09   ` sashiko-bot
2026-12-04 22:07   ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 03/10] inet: frag: reject fragments with mixed readability in reassembly Octavian Purdila
2026-12-04 18:38   ` Mina Almasry
2026-12-04 21:09     ` Octavian Purdila
2026-12-04 22:07   ` netdev-bot+sashiko [this message]
2026-12-03 21:09 ` [PATCH net 04/10] net: skbuff, skmsg, strparser: reject unreadable frags Octavian Purdila
2026-12-04 18:58   ` Mina Almasry
2026-12-04 21:25     ` Octavian Purdila
2026-12-04 21:09   ` sashiko-bot
2026-12-04 22:07   ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 05/10] tls: reject unreadable skbs in tls_strp Octavian Purdila
2026-12-04 18:44   ` Mina Almasry
2026-12-04 22:24     ` Octavian Purdila
2026-12-04 21:09   ` sashiko-bot
2026-12-04 22:07   ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 06/10] tcp: reject unreadable skbs on TCP-MD5 and TCP-AO Octavian Purdila
2026-12-04 18:46   ` Mina Almasry
2026-12-04 22:26     ` Octavian Purdila
2026-12-04 21:09   ` sashiko-bot
2026-12-04 22:07   ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 07/10] net: kunit: test unreadable net_iov napi_gro_frags Octavian Purdila
2026-12-04 18:47   ` Mina Almasry
2026-12-04 21:09   ` sashiko-bot
2026-12-04 22:07   ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 08/10] net: kunit: test unreadable net_iov defrag and skb helpers Octavian Purdila
2026-12-04 21:09   ` sashiko-bot
2026-12-04 22:07   ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 09/10] selftests: drv-net: devmem: test unreadable kTLS RX Octavian Purdila
2026-12-04 18:48   ` Mina Almasry
2026-12-04 22:28     ` Octavian Purdila
2026-12-04 21:09   ` sashiko-bot
2026-12-04 22:08   ` netdev-bot+sashiko
2026-12-03 21:09 ` [PATCH net 10/10] selftests: drv-net: devmem: test unreadable skbs on TCP-MD5 and TCP-AO Octavian Purdila
2026-12-04 21:09   ` sashiko-bot
2026-12-04 22:08   ` 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=179642206934.3146.322907419982921858@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=almasrymina@google.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=hawk@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jakub@cloudflare.com \
    --cc=jiayuan.chen@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=kaiyuanz@google.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mcroce@microsoft.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sd@queasysnail.net \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=tavip@google.com \
    --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