From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B27B0606A320 for ; Tue, 1 Dec 2026 12:39:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=lujOHTVL; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=h5lF21S7 Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 944226081F; Tue, 1 Dec 2026 12:39:27 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id KL6skGmdiaAy; Tue, 1 Dec 2026 12:39:25 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp3.osuosl.org EC11760873 Authentication-Results: smtp3.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1796128765; b=BXnl0wUsA7Yi/1pXpidw/VXg3Kx6DRZDdq4jH+pgVitHStwZI8zQML0Bjk4aOkL4SL+U t4m7ryV99QXXH9WdDFQ7Rpuxu2GdiGVeT90d3hCH4j2bY0Rhcxaq1gtNuYHM7JDxsFiIr uURW5sm5/rDZuj9YJakCVZZuL3Mc6RDxr2bV64GfxL0xz3Lt4DY3sOBUUMnNnX8eVYMLx qRiT4pos+OaX4+Szj9WXpnD9Ras/Xb+vQFyfrh7STLSjCwQD0zTEmcyczmBRUDPuNUWPi G17Sr/wUaIvlxuETCFT3z+BEiSiPoN9nGhdvvfwyWl9sQ0aIF8Hv7TicQHNGpdXpbHQ== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796128765; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received:Received: Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version:X-BeenThere:X-Mailman-Version: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: List-Subscribe:Errors-To; bh=EJ3RoREzbgxOmUs9YVkAnO1BtHTAvFFSnbP+HDwwkIg=; b=pEB9MlcbmzVuY7zHwiQhUkzdbwj3CLNEm/4NRB+Xdy8zkELJw2MtMfmVdS/vd1xLd9p7 WZ9oyHS5/YzNO9tMW3esA8jb5Q4u6r4mvWX1JwlXSf3jyB7vqxUw6qSRke61grT7IXtSq UJAkKs6TgUy9e08pY/DfqFSyGVZX+0qcsTFFzGQcs1qT0R59HT9Nqdxha0kV4qLQ6C/b4 5c8IRqw4EkYn3Cu8RrRIdP12ZjcrUV7MaC0ywnESuHJAba/yF37Fq69RtWecyghwJJFEw bSH4Xuy6sQUBKN/MAQGCqUmdPcIBi59JcryXX/31kyhEkRAEshRKyUHlGvGMkCwujwQ== ARC-Authentication-Results: i=1; smtp3.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1796128765; bh=EJ3RoREzbgxOmUs9YVkAnO1BtHTAvFFSnbP+HDwwkIg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lujOHTVLJTiZuC0ZH/CMYx7wXJiDAyZkLyId/Sz0okCS3YDcr4U5eEufE7KhNbqyq JMyBZL29ZV6DRLyUk2YTjMdH4UViMdVH3uHA2/8njqLZF+QaU2iJUjaT7r+P8lEZZN f7fdC9Mxahu6t812GklFt3+ygw29qHadY9KXBAwX+98mx+kr60ArBZWDwxj9hLLNUa cZKJD565wNfJFGap+feRoA4EOwQl9bXyFStnRrYxFzFEA/vnYdhiUh3WTU2tbOw4AA ntUl0Uomogy22SVlvShJst9zwr4afVmn6q7hZWVHL19411PcsOXYfRmMZB9oftcjOk oYZ7ezErut1Sw== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id EC11760873; Tue, 1 Dec 2026 12:39:24 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists1.osuosl.org (Postfix) with ESMTP id 09F64325 for ; Tue, 1 Dec 2026 12:39:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id EF3D580EA3 for ; Tue, 1 Dec 2026 12:39:23 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id qwB3Fw2zqiue for ; Tue, 1 Dec 2026 12:39:23 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp1.osuosl.org D90C680F1C Authentication-Results: smtp1.osuosl.org; arc=none smtp.remote-ip=172.105.4.254 Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=netdev-bot+sashiko@kernel.org; receiver= Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp1.osuosl.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: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by smtp1.osuosl.org (Postfix) with ESMTPS id D90C680F1C for ; Tue, 1 Dec 2026 12:39:22 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 8A04D624C3; Tue, 1 Dec 2026 12:39:21 +0000 (UTC) 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-Archived-By: MIME-Version: 1.0 X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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