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=1796380779; b=uzPXmVaw7CP9/wOoCHh1ewg97/Dfp0dp1Za3PJAf+EVfrH21EsSNSBkfiII75IE6gk1H Nfu0GtvcnRI+du+Lk1bEHKwcy2/qZm7S0E3D6F4bW8RgzHrr/SCfOfBjV8Z5JOF4DtGQa TqE6WDGhTeJ6HZ3CXRWq42Ig3GbfYRcBTFnsvI72qtn12tR/zyKhAzEIGUVK5p37+lxVk TUIlYukFJCeae0p6dsks9mFzAb4m5QR06B78aj/o4wgnIGFVh7KIGbJaMN69kAlOCdJLH qmAqYqpaBdpJbOOUOGMCzbiqtaK4YAHa1LNr75o3mPm3mss5x3J3CUHo6IgHSoxcy3A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380779; 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=PKFmj5ZNDapJCKJ82oIiLh5xRZr/fsNW3Ip8Xm/kAnc=; b=O+Z2iqYEEWNVrKjCal0xouXE9m93V9HzW8g/35vQ8XOXH6chiJNaKIVom7x4NhgdTUo9 oOIDkRIb6zG99q2zv4qqrQDuf+iq2ENqxNrpFp6NKuF8VYDO4huBEXCMXiX/0iKZMQbOk 4DJzjLUnquPKY1G7R9XM4U8dfruIEEHxxW3LaNCmWhLqMSvtlw/bCD10rZzyf+96xyiIT /4qxDSTDEsj2YwhTQtCt5QE73wYTxDafFGw/AVaPJtOMkc4PKj+Zdq9ZNz9WrKwh/RArk aIw4UhipqHdEYWB3+3wW2blVvcImfn0H6NGotWnsyM1n3UBUgeGFuTBQMkpOpfhhgVQ== 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=Sfmob8KV; 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 1C0F1606A32C; Fri, 4 Dec 2026 10:39:39 +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=Sfmob8KV Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DE671F00897; Fri, 4 Dec 2026 10:39:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796380778; bh=PKFmj5ZNDapJCKJ82oIiLh5xRZr/fsNW3Ip8Xm/kAnc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Sfmob8KVwyNdB6QmeYDV7dLkBJV3E3pxh2YnUpPnbQv6RQkcHKXgqte4bnmJLFGAW iCw0mdA+qPPmg9m2YIz4YLuZnd533yUj2dIE1KZw/YNO3UkVKFs0Hg2C7iP3Up1l/X laltjos+p6Fl64SBQZNDb9SpzC4ULagBEGrY2v4fSZLRBiAihGWrJlx6H+8KWhWxm4 dalnqUiVLvmFiWeaa1DxKHOIS0QAhmS7HLPEdZ94NhjdHtI2OCs39aaHRmZEU6Q9OV Tq71fBnM23ITlu/tnORx2HmCssVmB+MqP1rA0Z9mY+3UVnWB0dL4U/tbO8Y0MM/CMU 5l5Ux4NxIdv6A== Subject: Re: [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size 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:36 +0000 Message-ID: <179638077683.3146.7227826095174306078@kernel.org> In-Reply-To: <20261203095647.3448925-3-bjorn@kernel.org> References: <20261203095647.3448925-3-bjorn@kernel.org> X-sashiko-severity: Low 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 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 how much of the shared info the old xdp_build_skb_from_zc() let a sender overwrite. -- xdp: Size zero-copy skbs from the data, not the frame size This patch changes how xdp_build_skb_from_zc() sizes the skb head. It now uses data_end - data_hard_start instead of the XSk frame size, so packet data can no longer overwrite the skb_shared_info. It also copies the exact head and fragment lengths instead of rounding them up with LARGEST_ALIGN(). Heads larger than a page now come from __netdev_alloc_skb(). Link: https://lore.kernel.org/bpf/20260629072300.1664622-1-clecigne@google.com/ > With 2K chunks, no UMEM > headroom and the default MTU, a 1514 byte frame that XDP passes on > ice, idpf or gve needs 256 + 1514 + 320 = 2090 bytes and gets 2048. > The sender controls up to 48 bytes of the shared info, its frag list > among them. [Severity: Low] Is "up to 48 bytes" the real upper bound, or only the overflow for this example? The 48 bytes come from 1514 rounded up to 1520 by LARGEST_ALIGN(): 256 + 1520 + 320 - 2048 = 48. For single-buffer pools, xsk_pool_get_rx_frame_size() subtracts the shared info tailroom only for multi-buffer pools: include/net/xdp_sock_drv.h:xsk_pool_get_rx_frame_size() { ... mbuf = pool->dev && (umem->flags & XDP_UMEM_SG_FLAG); frame_size -= xsk_pool_get_tailroom(mbuf); return ALIGN_DOWN(frame_size, 128); } xp_create_and_assign_umem() sets frame_sz to the whole chunk: xskb->xdp.frame_sz = umem->chunk_size - umem->headroom; The commit message says a device may fill a single-buffer frame to its end. In that case data_end - data_hard_start can equal frame_sz. One example is a 2K chunk whose 1792 byte rx buffer is filled after a raised MTU. Another is 4K chunks with 3840 byte frames. The old code built the head with napi_build_skb(data, xdp->frame_sz). That left only frame_sz - 320 bytes of linear room. So the copy would overwrite all of SKB_DATA_ALIGN(sizeof(struct skb_shared_info)), which is 320 bytes on x86_64, including frags[]. With 4K chunks, the LARGEST_ALIGN() rounding could also write past the page handed out by the system page pool. The sender also controls more than the frag list in the first 48 bytes. The flags, nr_frags, frag_list, dataref and destructor_arg fields all sit there. A chosen SKBFL_ZEROCOPY_* flag combined with a chosen destructor_arg gives a callback pointer. Could the commit message give the worst case as the whole shared info rather than 48 bytes? The code change closes the whole overflow. Only the stated impact looks understated. -- Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203095647.3448925-1-bjorn%40kernel.org