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=1796128761; b=YWuIEl1w5PRnL7DMZ21OKIYsK4t6F1K5cmJCh5a5CZiicT+abhl+k27hVTsMv8STX0jR CcHUzlyUQXKkPfokPwnCqcBFsGuvcDDqg94sePlLD/+WaNRRKi5jplOeLO8olxSpQbUnX NpCBwUHeBybDizexS8P6eWxJxqOtBH4j1r/SiU85yvLuLRScExPybOeRTzg5FUlYvkbas 8F9IpbTIwCECcW/hGBaQHwRqph3dbU3Js0lCqgaDhM85JhkAzHhjOWO6npt03M5Kedq+y uZleA5ynHTwIkcdfiPfmNH0jsEAdSYM0uNB/9L1Pl1rjrhNB/+UQJGOaz710hqBlkAw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796128761; 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=EJ3RoREzbgxOmUs9YVkAnO1BtHTAvFFSnbP+HDwwkIg=; b=hZiXYfWLHzHvvnvq4KwoIKJoScha8fLxqTG0iDcRZJxKmnXn7PX906E3JsaPP5QBHsST qM9XRpOCsUpvpkhyDnekkwoQ/8RSS8+41+GXqtllc3+yRIZ0mTDmdUD5pwb8XrvJbLAgJ 40jpK79J59tXIm6B9MxlAUkcVBaflsQkYe5Mv6qHp72B40U9bpKnJD0vJdS3d6Cpwkc3S +5O4dRYlIULPRhqu6qf29Rf4+Xx+wL5wNo8gkzsle6qQGxi/4V6msSZyLMuJcB7ZAhX1P 0ddtuQGEweEJ3Zfa1gHy8h6MUHSVUZ+hpu3ajLEteMoOeAP4djKV27dIuglRK0LB1qQ== 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=h5lF21S7; 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 A3AA7606A32F; Tue, 1 Dec 2026 12:39:21 +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=h5lF21S7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D9CA1F00897; Tue, 1 Dec 2026 12:39:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796128761; bh=EJ3RoREzbgxOmUs9YVkAnO1BtHTAvFFSnbP+HDwwkIg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=h5lF21S7GtFC7UcKfha4qI1pIN0eTbY9CEBnnp3WCBIzwa76KgABoXikcT7Z53ZqN HP4qRPQFoPcWfmbUXKQHV1XAISpnKI/bbQb+02xLL9wDTvOI88m7L4Xa5Emu2QA5v7 Qqq6peVVVidmMPXav4IiyiP+oVLDryb363COngbgSd0g0jwroNkWngB940jXFLBsYb hQ/OQhMmB5ucG4VgZo8CFocT48LQ3t90dxkpC08ZwImBAl3LMaao5GupwAQ2T/+eB6 F98F/bcU8DNVy/WmHN69vcvRYBihn2pmeslM5FU0BOeMKbo5EudwKE77OaIOdWVULF xNmoXwy/ApS0w== Subject: Re: [PATCH net v2 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory From: netdev-bot+sashiko@kernel.org To: bjorn@kernel.org Cc: magnus.karlsson@intel.com, maciej.fijalkowski@intel.com, aleksander.lobakin@intel.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, netdev@vger.kernel.org, bpf@vger.kernel.org, horms@kernel.org, sdf@fomichev.me, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, intel-wired-lan@lists.osuosl.org, clecigne@google.com Date: Tue, 01 Dec 2026 12:39:19 +0000 Message-ID: <179612875904.3146.8079683295083998736@kernel.org> In-Reply-To: <20261130123737.125432-5-bjorn@kernel.org> References: <20261130123737.125432-5-bjorn@kernel.org> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@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 2 potential issue(s) to consider. Critical: 0 (1) · High: 0 · Medium: 1 · Low: 1 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] Logic inconsistency (length limits). - [Low] Commit message: undisclosed stable prerequisites. Pre-existing issues: - [Critical] This problem wasn't introduced by this patch, but the patch's premise is that "Userspace may write the UMEM at any time". -- xsk: Keep the shared info of zero-copy buffers in kernel memory This patch moves the skb_shared_info of multi-buffer XSk zero-copy packets out of the UMEM chunk tailroom and into the buffer pool. Pool buffers are marked with the new XDP_FLAGS_SINFO_EXT flag. For those buffers xdp_data_hard_end() reserves no tailroom, so the device and bpf_xdp_adjust_tail() can use the whole chunk. > Keep the shared info in the buffer pool, which outlives its buffers > and the queues that point to it, and let the device write up to the > end of the chunk. One shared info per pool is enough, as a pool builds > one multi-buffer packet at a time. libeth read it later, at an XDP_TX > bulk flush, which an earlier patch of this series fixes. [ ... ] > Multi-buffer pools now give the device the whole chunk, as > single-buffer pools already do. Every UMEM accepts a larger headroom, > also in copy mode, and bpf_xdp_adjust_tail() can grow a zero-copy > packet up to the end of its chunk. [Severity: Low] The message names only the libeth prerequisite. Does this patch also depend on two other commits from the same series? "xdp: Size zero-copy skbs from the data, not the frame size" "intel: Copy the exact length of XSk packets to skbs" Both of them say "The last patch of this series lets multi-buffer pools and bpf_xdp_adjust_tail() reach the end of a chunk". The intel one describes a page fault on the guard page after the UMEM, from the memcpy in igb_clean_rx_irq_zc(), when the tail is grown to the chunk end. This patch carries Fixes: 24ea50127ecf, so it is a stable candidate. If it is backported without those two commits, the over-reads in the intel drivers and the shared-info overwrite in xdp_build_skb_from_zc() would become reachable on igb/igc/ixgbe. Could the message name those commits as well, or add stable dependency annotations for them? > diff --git a/include/net/xdp.h b/include/net/xdp.h > index 07231adfb5f82..0524027669882 100644 > --- a/include/net/xdp.h > +++ b/include/net/xdp.h [ ... ] > @@ -178,17 +189,26 @@ xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start, [ ... ] > -#define xdp_data_hard_end(xdp) \ > - ((xdp)->data_hard_start + (xdp)->frame_sz - \ > - SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) > +static __always_inline void *xdp_data_hard_end(const struct xdp_buff *xdp) > +{ > + u32 tailroom = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); > + > + if (xdp->flags & XDP_FLAGS_SINFO_EXT) > + tailroom = 0; > + return xdp->data_hard_start + xdp->frame_sz - tailroom; > +} [Severity: Medium] With XDP_FLAGS_SINFO_EXT set, bpf_xdp_adjust_tail() can now grow data_end up to data_hard_start + frame_sz. xsk_rcv_check() in net/xdp/xsk.c was not updated. Does it still agree with this new bound? net/xdp/xsk.c:xsk_rcv_check() { ... if (len > __xsk_pool_get_rx_frame_size(xs->pool) && !xs->sg) { xs->rx_dropped++; return -ENOSPC; } ... } __xsk_pool_get_rx_frame_size() is chunk_size - umem headroom - XDP_PACKET_HEADROOM, which is frame_sz - 256. Take a zero-copy socket bound without XDP_USE_SG. A program can call bpf_xdp_adjust_head() with a negative offset, which moves data down to data_hard_start + sizeof(struct xdp_frame). It can then call bpf_xdp_adjust_tail() to reach the chunk end. That gives a linear packet of up to frame_sz - 40 bytes. Both helpers succeed. After the redirect to the XSKMAP, xsk_rcv()->xsk_rcv_check() drops the packet and increments rx_dropped, even though the data fits inside its own chunk. Before this patch, bpf_xdp_adjust_tail() capped data_end at 320 bytes before the chunk end and returned -EINVAL, so the program saw the failure. bpf_xdp_adjust_head() alone could already exceed this check when a single-buffer device filled the chunk to its end. This patch extends the mismatch to the adjust_tail range on any UMEM layout. Should xsk_rcv_check() use a bound that matches xdp_data_hard_end() for zero-copy buffers? [ ... ] > diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c > index 5ec092f7cb6f7..28bdc63551bfc 100644 > --- a/net/xdp/xsk_buff_pool.c > +++ b/net/xdp/xsk_buff_pool.c [ ... ] > @@ -125,8 +126,15 @@ void xp_set_rxq_info(struct xsk_buff_pool *pool, struct xdp_rxq_info *rxq) > { > u32 i; > > + /* Userspace may write the UMEM. Keep the shared info in the pool, > + * and let the device write up to the end of each chunk. A NAPI may > + * still run on the buffers, so publish the shared info first. > + */ [Severity: Critical] This is a pre-existing issue and was not introduced by this patch, but it is in the class of bug this patch closes. dpaa2 stores a kernel pointer inside the UMEM chunk, which userspace can write. drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c:dpaa2_eth_seed_pool() { ... swa = (struct dpaa2_eth_swa *)(xdp_buffs[i]->data_hard_start + DPAA2_ETH_RX_HWA_SIZE); swa->xsk.xdp_buff = xdp_buffs[i]; ... } data_hard_start points into the vmap of the pinned user UMEM pages. On RX, dpaa2_xsk_rx()->dpaa2_xsk_run_xdp() reads the pointer back from the same chunk and writes through it: drivers/net/ethernet/freescale/dpaa2/dpaa2-xsk.c:dpaa2_xsk_run_xdp() { ... swa = (struct dpaa2_eth_swa *)(vaddr + DPAA2_ETH_RX_HWA_SIZE + ch->xsk_pool->umem->headroom); xdp_buff = swa->xsk.xdp_buff; xdp_buff->data_hard_start = vaddr; xdp_buff->data = vaddr + dpaa2_fd_get_offset(fd); ... } It then runs the XDP program on that buffer and passes it to xdp_do_redirect(). dpaa2_eth_free_bufs() also reads swa->xsk.xdp_buff from the chunk on teardown and passes it to xsk_buff_free(): drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c:dpaa2_eth_free_bufs() { ... swa = (struct dpaa2_eth_swa *) (vaddr + DPAA2_ETH_RX_HWA_SIZE); xdp_buff = swa->xsk.xdp_buff; xsk_buff_free(xdp_buff); ... } The pointer is not validated on either path. The chunk can sit in the fill ring or the hardware buffer pool. Can a process that owns the UMEM overwrite these 8 bytes during that window? The kernel would then write through, and do list operations on, an address that userspace chose. > + rxq->ext_sinfo = &pool->sinfo; > + /* Pairs with READ_ONCE(xdp->rxq) in xdp_get_shared_info_from_buff() */ > + smp_wmb(); > for (i = 0; i < pool->heads_cnt; i++) > - pool->heads[i].xdp.rxq = rxq; > + WRITE_ONCE(pool->heads[i].xdp.rxq, rxq); > } > EXPORT_SYMBOL(xp_set_rxq_info); [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130123737.125432-1-bjorn%40kernel.org