From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA0FE1F0093B; Fri, 4 Dec 2026 22:07:49 +0000 (UTC) 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== Subject: Re: [PATCH net 03/10] inet: frag: reject fragments with mixed readability in reassembly 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 Date: Fri, 04 Dec 2026 22:07:49 +0000 Message-ID: <179642206934.3146.322907419982921858@kernel.org> In-Reply-To: <26a527b0c0dc802b38a8a25081a101b4e3263841.1796329894.git.tavip@google.com> References: <26a527b0c0dc802b38a8a25081a101b4e3263841.1796329894.git.tavip@google.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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