From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 68085606A322 for ; Fri, 4 Dec 2026 10:39:47 +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=UlNJHi63; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=F9uB26Y6 Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 4840C40E08; Fri, 4 Dec 2026 10:39:47 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Qhl-7Q3ufF3r; Fri, 4 Dec 2026 10:39:46 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp4.osuosl.org 4FBB140D4E Authentication-Results: smtp4.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=1796380786; b=pJuLeg4gVxLGOT5lcijD/p7vuSJeKmjNKkeB9azkQHaMBpq6GG+2QEv+Pi5f8plpmfTi lynFdIMRI5/Dt4APX27q+RftdbNXdAVX485GjPoLeBhR/45D7Uc67edXoHzQFYXfFsxeq 3twTCghAyRVlJpSGx3kAE+302cbWoffu/zyMaQosyvDCOi538rSt2BhJQiZMFhRyCBY8B ZCBkfYMAGCzeyanpRxz7Wwloj2tybaxp6B3fx3A+TgbfSWpGz5+J5unAS+5zOrEoOOF+6 GayixS4MwHyV63AqU6vBplfOUxIOjDikRgHtmkclc8jsCCfTCFr2cKyab6r9OXHTuHQ== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796380786; 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=NvMqtwTJ0gPIXlQ2cGXtbbpJEcWjV1pfZphOh2t3qU8=; b=m/jCdrXxfcH3bfxNfjJfTy3gVjAD4LMv/+CJYz/K4tABgWlHPnYD6pTUXbHzAXSPknQ3 Rb8jJ622phSFwkzHb6/1GL3QS2rIHq1dYZjfvTBB43glYgaL0HzLJKVeh2NJBFMJlScUr E/DKnfl2XvioGUEm8LzD65lITFNgpkzCB35xeDXw2+I0sFCXE8bg/9662mJwm2DqyAH2Z vROdRK32mtwYMqlTkVRIw5bSxQ7Dse0FAv5KR/xy4qjMTVlkH/ZwzYDcwHGeTVv3RYeph XpxsY56/SzRJtH52myDhv2eTi4VNVaJWEN8AfXNUO2PYunD+Rcrk3P9QlW/XHqZ2MVA== ARC-Authentication-Results: i=1; smtp4.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=1796380786; bh=NvMqtwTJ0gPIXlQ2cGXtbbpJEcWjV1pfZphOh2t3qU8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=UlNJHi63F6V6OPPRWihC/g4lrCXIBxFWRFGRv9NyyYz24l67xjS4ghuPD1WJAiJkq QjEqU9eZXHhNdpI2W28oUmiUfTigbzoF0YA0QOrJYEY2Zx5MIAPzxQrQUmeoUfp3A9 ERVONKqWi8/9bLA6WI6nE9u13dDoEFKPgpK3OyyA0Oy7bo2s+mNluLfGG+raUCAfkf gdaQNWPRSpYvydJyC7t7Vf+tELaa1E1unfebEMcofpP+w4YpQHVHuuNxAYsyzg6TKz Dkw93rrPzHm36Qck1GdNUgUHJkR2+1ENNl9SYVAx+vg2wMuhqk69M31Muq0BxdKbXp fVpvrpJa+X7qQ== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id 4FBB140D4E; Fri, 4 Dec 2026 10:39:46 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists1.osuosl.org (Postfix) with ESMTP id 214712A8 for ; Fri, 4 Dec 2026 10:39:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 075AE849D2 for ; Fri, 4 Dec 2026 10:39:45 +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 kRke4OpLv6N0 for ; Fri, 4 Dec 2026 10:39:43 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp1.osuosl.org 99ABC83FB6 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, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=F9uB26Y6 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by smtp1.osuosl.org (Postfix) with ESMTPS id 99ABC83FB6 for ; Fri, 4 Dec 2026 10:39:42 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 9735E62D72; Fri, 4 Dec 2026 10:39:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FE9E1F000CE; Fri, 4 Dec 2026 10:39:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796380781; bh=NvMqtwTJ0gPIXlQ2cGXtbbpJEcWjV1pfZphOh2t3qU8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=F9uB26Y6d9D2IB8pyuZ8ZPDzAzaNyvjZULAmbKtb8yO2d9YaSQGqawNn0K4CYKyjC hDCF9mrSVRP3YGPpygG9WLffJiy3xxEWdfXUM54jWp5W8rCCjs9Ha+aIToPEDhuSTf WL3/rGA4+p3SQZ0ckvFM87D7yC7ygpcyO6ZmZXl6y2daBw/D3T4SYIeWWjQB+prtfO 2HkuQYWCRTv/YA2xujQ8UbZCVrGkL+WJnFTl4FPCiMhE78UJWo2LiIkU9/lDwSp/Zv 8UQGbSe3sIqyzkqVp9i8PZuKvVJYyzhFdqDydSP/E99+RxRn97CZLA4VmpFUoh/nd/ ez+3weobvMYZA== Subject: Re: [PATCH net v3 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, andrew+netdev@lunn.ch, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.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, intel-wired-lan@lists.osuosl.org, clecigne@google.com, michal.swiatkowski@linux.intel.com, sriram.yagnaraman@ericsson.com, kurt@linutronix.de Date: Fri, 04 Dec 2026 10:39:39 +0000 Message-ID: <179638077906.3146.4204032299868924468@kernel.org> In-Reply-To: <20261203095647.3448925-5-bjorn@kernel.org> References: <20261203095647.3448925-5-bjorn@kernel.org> X-sashiko-severity: Low 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=-11.3 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_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 more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] The commit message understates the bug it fixes. - [Low] The AF_XDP selftests still model the old UMEM layout, in which ZC multi-buffer pools reserved skb_shared_info tailroom at the end of… -- xsk: Keep the shared info of zero-copy buffers in kernel memory This moves the skb_shared_info of zero-copy multi-buffer packets out of the user-writable UMEM chunk tailroom and into the xsk_buff_pool. A new XDP_FLAGS_SINFO_EXT flag tells xdp_get_shared_info_from_buff() to use rxq->ext_sinfo, and xdp_data_hard_end() then reserves no tailroom. The UMEM headroom limit in xdp_umem_reg() is relaxed to match. > A packet that a driver receives in zero-copy mode over several buffers > keeps its shared info, the fragment list and its count, in the > tailroom of the UMEM chunk of its head. Userspace may write the UMEM > at any time, also while the kernel walks the fragments, and a > rewritten list or count makes the kernel read and write out of bounds. [Severity: Low] Does "read and write out of bounds" fully describe the impact? Before this patch, xdp_get_shared_info_from_buff() returned a pointer into the UMEM chunk tailroom for a zero-copy head. Each skb_frag_t stored there holds a netmem_ref plus len and offset. That means userspace could forge the page pointer, the length and the offset, not just nr_frags. The consumers use those values directly. xdp_copy_frags_from_zc() does: memcpy(page_address(page) + offset, skb_frag_address(frag), len); This copies from a kernel address that userspace chooses into an skb that is passed up the stack. bpf_xdp_frags_increase_tail() does: memset(skb_frag_address(frag) + skb_frag_size(frag), 0, offset); This writes at an address that userspace chooses. __xdp_buff_add_frag() also reads nr_frags back from the UMEM. It only rejects nr_frags == MAX_SKB_FRAGS, so a forged count of up to 255 sends the frags[] write far past the chunk. This gives userspace a kernel read and write at addresses it picks, not an access limited to the area next to the chunk. To reach it you need ns_capable(CAP_NET_RAW) in xsk_create(), a netdev that supports zero-copy, and an AF_XDP socket bound with XDP_USE_SG in zero-copy mode. Could the commit message state the real impact and the privilege needed? Stable reviewers and backporters use that to triage. The patch also relaxes the headroom check in xdp_umem_reg(), so they need it to weigh that change. > 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: Low] Should the AF_XDP selftests be updated along with this layout change? They still assume that zero-copy multi-buffer chunks reserve skb_shared_info tailroom at the end. test_xsk() in prog_tests/xsk.c and main() in xskxceiver.c both compute: /* 48 bytes is a part of skb_shared_info w/o frags array; * 16 bytes is sizeof(skb_frag_t) */ umem_tailroom = ALIGN(48 + (max_frags * 16), cache_line_size); In prog_tests/test_xsk.c, testapp_adjust_tail_grow_mb() still has the comment "4k is truesize, 3k payload, 256 HR, 320 TR". It also subtracts umem_tailroom from grow_size. testapp_stats_rx_dropped() subtracts umem_tr when it sets frame_headroom. That lands exactly on the old xdp_umem_reg() limit (4096 - 256 - 128 - 320 = 3392). These sizes are conservative, so the tests still pass. However, no test covers a zero-copy bpf_xdp_adjust_tail() grow up to the end of the chunk. No test uses a UMEM headroom above the old limit either. Wouldn't these tests pass just the same if the kernel still reserved the tailroom? > > static inline struct skb_shared_info * > xdp_get_shared_info_from_buff(const struct xdp_buff *xdp) > { > + if (xdp->flags & XDP_FLAGS_SINFO_EXT) > + return READ_ONCE(xdp->rxq)->ext_sinfo; > + > return (struct skb_shared_info *)xdp_data_hard_end(xdp); > } [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203095647.3448925-1-bjorn%40kernel.org