🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27164

Re: [PATCH net 03/10] inet: frag: reject fragments with mixed readability in reassembly

#27164
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 22:07
184 lines
14959 bytes
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
Technical Details
Message-ID: <179642206934.3146.322907419982921858@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!peer05.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377687-linux-kernel-netdev=dewy.ru
References: <26a527b0c0dc802b38a8a25081a101b4e3263841.1796329894.git.tavip@google.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!peer05.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377687-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 03/10] inet: frag: reject fragments with mixed readability in reassembly
Date: Fri, 04 Dec 2026 22:07:49 +0000
Organization: Usenet Network
Message-ID: <179642206934.3146.322907419982921858@kernel.org>
References: <26a527b0c0dc802b38a8a25081a101b4e3263841.1796329894.git.tavip@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="2884068"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:pA2RvMMrmaDJ5fJEov1dmimF3Xk= sha256:2cwE/jJ43y8pUaFSF5sqsv0cvBXYVZemjqKJzfd13mg= sha1:Kx9dxise1iM/gisTfyZo6IhvSLs= sha256:A8+TeCN94ri6iXDW4zVyXdJ9YvO14cntrH1fObiYcTQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 7510D117D0B; Sat,  5 Dec 2026 01:08:42 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.541
X-Spam-Status: No, score=-3.541 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ES2Foc1ktCZT; Sat,  5 Dec 2026 01:08:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377687-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 61E76117D0C; Sat,  5 Dec 2026 01:08:31 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id C6CCF3EE2A; Fri,  4 Dec 2026 22:07:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796422077; b=s9ZnsKa5b3Gz5JppposRPneiPyCEPxe35LnjZBuRQ1IpOUSWmLsXk159z403xHEU2iZc KaA9mHLSCw/9y6kTV8mX5jllB37laRWocc55V+5bGsvRZZ6pZ60nOL1UjUsBoFByPZWnd x7xRLm0hEu1NJeokziqoZrrQJrHRVF/ghfseU6yEMHb80lsra+msV0oCaX9uffvpJwIQU Hu4pImc+nJPsjxBt96wKwb1Ff6TIk9gpqOFmF6JXoB5NkE6MmmdBMRMQNUv/ioAHebKGs z4UQNvcxL6IZZ3Q207ukJrbVCB/HCagfX7/+FnJOXCXGY/gtj6B8Dg5ZDYMXIWpzfzw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796422077; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=m6acV20pWAd5PoEMOuNwvFBzxqUeosrEK0QUel5t13w=; b=CP5+GPlGNFCDfkgBWUcxoCxPF9EZmdIqC4SbVlwbCgzvWwC10bGEtv3yS2ugYnkTXKrQ uda2ruxqofu5DuzPYMSHdtQOEI0yK0IeYKDWURQgeVMNHZwckanq4cDYji04BmjjqHhq9 6yFLiOW15XH5GqfuzqnX2dq41zOInapgiVGbLBFVeaVXK1mxaFEHB5v9lVxfO9/mfp4Ti QPoZEYAE7fyEmodFp6mDgPrC7aNjtDj1XlqjquI0XHURVlGbLgjKuN+UFcgO1GUhDHXNV Zynka0IZFSC5MVvOk2ltjBeG57gYJP9rsOcjl/7o3e05nMwmUHnjZwLa4zllmBLRnVQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Wx14qzUU; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99EA7606A334; Fri,  4 Dec 2026 22:07:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Wx14qzUU
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796422071; b=0QVsLOTaDAT1Xih5xqQyGjy/a2RitYf0GnqNhXwWlugar4DyrpUhxyX243vUAHH0xgsI 8b2E4xmPT+v1312y+vbkzEVBytIf+HezW6cfKqp8vMyL/B0qRwAZA36ZYAfjnLbc+NioE wUyewgeNx8jWpSbmqvTu6dYehSHresBA0AMwXVM+aptikkOWk3YU0+meM7vLlv6bhVlFM q2t/AUGdw8WM7BonqFBFl5SWpRP2AhNwyZNo1DTOisHrj5PlsP7evWokqQNk77/flZhv4 DVugJF7MNp3ZbzM5FX/b5a1BKGOaiJv8+/fYlsygfsKgpiQtXVNpEWgf9Siff8f2HmQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796422071; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=m6acV20pWAd5PoEMOuNwvFBzxqUeosrEK0QUel5t13w=; b=0IOTg1OHYoee2DFYJUSZDdz2LbB8ne5qm1QemK/5N7IiGaZW3z1I+5AnVv+nNDMoSWYG ZbOa2DmPgZwk35RvgyhGxiiTrn28I5IdPBwrGFYDbuqs22sLIobzsMBhgMLAdcreKp0wj XEIFRkvSNqj3ft5ds2WgZ8Jh7vAV9HvySjoGytrbyI6MGGX3a27M7POsFUdCzh+/4xI/0 9S96VJWrvYZJzEulh0hAwCFR1OJYu3L18QJlU1xNMcxY51mmPp+OaNt3yBBQ08nDVTTEv nfTqSTttuoLyrijbTVW+S1y1nLuHkiOJwjounoujrkpOki9J8/rISHWoREnIAZoXoIw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Wx14qzUU; arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7788606A322; Fri,  4 Dec 2026 22:07:51 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA0FE1F0093B; Fri,  4 Dec 2026 22:07:49 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796422071; bh=m6acV20pWAd5PoEMOuNwvFBzxqUeosrEK0QUel5t13w=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Wx14qzUUkfG2UuV5gGkqTKYymga++kwrE7SbxYWP/R8xXp6W6Qlnz1OYviFUMJRQg 1ckaEacovLw7rgI8vc4QSwDRJhrgGAE6K+0bUyC/aBHMaf6LoH8Xf+fB+BbjEiZwrs I4Bf0/3+dZT0xN8TBYH/QmAcXKcCP7nBIleYZQvCkIt0DB8ncXG2+8cH9XAQHubIAO 8jmrQ/Dv6qb4U6uIqyuYEM2wuS1tJ9lhQIsbSZUXP5p6ZEbEqZuJFBZQ3PFlPx774c SFjAmvY7SefM8+lFK47eEOvonC2dT/uvZ08iPKXNp/Sm8M5UOUw15+BgMREYheFdKP ehqA7/XXRPtwg==
X-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
X-In-Reply-To: <26a527b0c0dc802b38a8a25081a101b4e3263841.1796329894.git.tavip@google.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Received-Bytes: 14762