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=1796128758; b=MUOzFwVRgfGVW2AMyCuB3agnkZ901gQhGCMTPUd/MTLt/KA2eEd+AJPmDUWr78qsGmcv YIe2JfdNpmKjtpvMor5/7ny3rrfJ6UJVNy70SLNuf/VgJ39nkYCEqMVal5LhWf6ydC3ht luKw1neGQkelHev45awrCL/bmyC1X0ZgC6EtRkuuLTcHQkFjHVsMhScZ4pR7K1TcoWauf av3M4a4kDSXE2KZYRAHVNqI4rZXo7VNvqrVR1vpB6zmm9lOpF9oeO7mrge8rofpll9xZk OpwkquvR+diInl7zUyJi0w9EKynyzG9bUNp7xq7N6sd63fYk7EnyrpGh+jie7G1qeNQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796128758; 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=M1SYmdFe7BALv0lj9LIeV+RaNfoTb3vaTEODieEJmFo=; b=WCDSvaYYTqzCDPMNXfX12S7Visbr0IkrUx29MTlXNRs98kUu8OlkI+uIZI/b8KBVDiPw f4crk4NkFHXtjy6CVAueexAMKPQNxylsaL86HavK5iZIv45goc4nick52+FitewSWqzao RBNBWWE+KGoh28exzc5SqFXdE03+R5afG/Pu9BfhpEF2uTXwZ6iYtXSeAl6U1z1JnK4GM rYvPoo999edlJ4ui13K5K9X3yugDAFqNYu6lRr500yF33HTZYm6/U74hLmJpnIYz5i4Yn QM34XDPPlyreNEZwgNUHsA9yVQY6PEVeIha5dZaJ+5OjyKfF7D6oiYFtQ82a/QhNGQw== 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=crMsqrSZ; 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 B6D03606A338; Tue, 1 Dec 2026 12:39:18 +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=crMsqrSZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD52F1F000C1; Tue, 1 Dec 2026 12:39:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796128758; bh=M1SYmdFe7BALv0lj9LIeV+RaNfoTb3vaTEODieEJmFo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=crMsqrSZIHMd6ImtF1P1VAigt4kFpS4qFGNAEGECG6d42/fAUfrkqQ7RYHxdBiMwo uj+fPrGDU3odovfnkSUES/x8s3SdnxTmymKABkVfV20LsISPrc7vBJn/EKHCs2bGOn JOyBUm57KcjveMoe8D0++yonuMYjlyp/n55D4WNFu8a5iC9r/URRRLJWN8SwbpPNrF rdeEa4YRNMqE3/2U5U2RNCNsfuCxUJ7wF/gI+Hxc1soF8+FexgO6r2jVD6FLieju1A 0FNFhyZNoQ91Nmm8PZWTqefe1Ku7/63RafHrNqrhAasvfpv+Y+FdeAkmJJtoodG90o 4C9MCsc6G3b5w== Subject: Re: [PATCH net v2 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, 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:16 +0000 Message-ID: <179612875635.3146.8031227810272631513@kernel.org> In-Reply-To: <20261130123737.125432-3-bjorn@kernel.org> References: <20261130123737.125432-3-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 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 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 commit message makes the overflow fixed by this patch look narrower than it is. -- xdp: Size zero-copy skbs from the data, not the frame size This commit changes xdp_build_skb_from_zc() to size the skb head from the data instead of the XSk frame size, so long packets no longer overwrite the skb shared info. It also stops rounding the head and fragment copies up with LARGEST_ALIGN(). Heads that do not fit in a page now get a kmalloc'd head from __netdev_alloc_skb(). Link: https://lore.kernel.org/bpf/20260629072300.1664622-1-clecigne@google.com/ > xdp_build_skb_from_zc() gives the skb head the frame size of the XSk > buffer, and the skb shared info takes the end of it. A device may fill > a single-buffer XSk frame to its end, so a long packet overwrites the > shared info of the new skb with packet data. For example, with 4K > chunks, MTU 3800, an xdp.frags program that returns XDP_PASS and a > socket bound without XDP_USE_SG, a 3814 byte frame needs 256 + 3814 + > 320 = 4390 bytes and gets 4096. The last patch of this series lets > multi-buffer pools and bpf_xdp_adjust_tail() reach the end of the > frame as well. [ ... ] > Reported by Clément Lecigne, and found again by an AI code review > agent. Reproduced only with out-of-tree code: a test module, and the > AF_XDP page-pool RFC on fbnic in QEMU. [Severity: Medium] Does this description make the overflow look harder to hit than it is? The example needs 4K chunks, MTU 3800, an xdp.frags program and a non-SG socket. In the baseline tree, the old xdp_build_skb_from_zc() also seems to overflow with a common setup: - 2K chunks - no UMEM headroom - the default 1500 MTU - any XDP program that returns XDP_PASS on a zero-copy queue No frags program is needed. In-tree drivers reach this function on every XDP_PASS: ice_clean_rx_irq_zc()->xdp_build_skb_from_zc() __libeth_xsk_run_pass()->xdp_build_skb_from_zc() (idpf via libeth) gve_rx_xsk_dqo()->xdp_build_skb_from_zc() The pool sizes for that setup come from here: net/xdp/xsk_buff_pool.c:xp_create_and_assign_umem() { ... pool->frame_len = umem->chunk_size - umem->headroom - XDP_PACKET_HEADROOM; ... xskb->xdp.frame_sz = umem->chunk_size - umem->headroom; ... } This gives frame_sz = 2048 and frame_len = 1792. For a pool without XDP_UMEM_SG_FLAG, xsk_pool_get_rx_frame_size() reserves no tailroom. It returns ALIGN_DOWN(1792, 128) = 1792, and libeth gives that to the device as fq->buf_len. The old code then did: u32 truesize = xdp->frame_sz; ... skb = napi_build_skb(data, truesize); ... skb_reserve(skb, xdp->data_meta - xdp->data_hard_start); memcpy(__skb_put(skb, len), xdp->data_meta, LARGEST_ALIGN(len)); The system page pool returns a 2048-byte fragment. Then napi_build_skb()->__finalize_skb_around() puts skb->end at 2048 - 320 = 1728. skb_reserve(256) plus __skb_put(1514) moves tail to 1770. The memcpy() of LARGEST_ALIGN(1514) = 1520 bytes then writes up to offset 1776. That overwrites 48 bytes of the skb_shared_info that was just initialised (nr_frags, frag_list, gso_*, dataref, destructor_arg). The sender of any full-size 1500 MTU frame controls those bytes. The new code handles this case: size = 1770, SKB_HEAD_ALIGN(1770) = 2112, and end = 1792. The concern is only with the changelog. Could the commit message describe the 2K chunk / standard MTU case on in-tree drivers and the remote memory corruption impact? It currently says "Reproduced only with out-of-tree code". The fuller description would help stable and CVE triage judge how urgent the fix is. The changelogs of the later patches in the series, "intel: Copy the exact length of XSk packets to skbs" and "xsk: Keep the shared info of zero-copy buffers in kernel memory", don't seem to cover this case either. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130123737.125432-1-bjorn%40kernel.org