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=1796467547; b=4nQhqISYlLvukLbxjT5m4W3XmkF2v1DnOZnYsOYJdpGcbkFldXM+UDiRCvs++0uqoFWl 4LA6d//U+LbGgtM7rvA4q1Ve706Bqxh0yN0X9ShfmQJpb1hp76qyP1R28PdfaBXbD9ZdI Hia2pac0AATWgvL2Ao/gDAOYHK0jFFtozi6UA0frUaObH0LQXkISR5e0apS45Hqs+/WNM iZoihQXRpWHrk2XjR3EttbHDCbE3/dFrLW8KWMsNd8RNOLfOLrCXU5ajHZ7IfwHCXkoBa pRKpqy4zJTB9slP+shlYYSjStdgWAeWyuhPvRmht+5p3sOeWQ5ggt2DFfaSX2p5hNzA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796467547; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=HMs3s34Ibg35NLjJDJL4U0n2LGtDSjMtMmxawt6f9nA=; b=ZuACp/pL8GSjnRgfsZsxCdyx67RRO1E0gMSQ7AkE+axA80ymuqzODWCDH/aCkTIjQWZr KzoGPPBSlktmfChDamY/UPC0Bmlcn0B7tyDd2IvoX+ZUA84jwtOQXZcH/sDnub8TQWc1+ ajux7Guh79JKCfXzv3NX+dCYjfXioTYec9T69BqbvWCL7QUzNsHy2HJG8rzXvh0RIyLSN aD0i7XYtuHU3vKHjitbeusMRtGMOD8rfC1TGOu0kJptRfIqhi1OF7iFkb94Znc91AHeGG nb/ZnAyL1VANbAMtTL32guRU8D9HhNXjZRPK/K1PxeIFRsL9NavZ96JWiouqL77af2w== 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=YqteCz11; 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 40996606A335 for ; Sat, 5 Dec 2026 10:45:46 +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=YqteCz11 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7DFB1F00A10; Sat, 5 Dec 2026 10:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796467546; bh=HMs3s34Ibg35NLjJDJL4U0n2LGtDSjMtMmxawt6f9nA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=YqteCz11+/kMt4Yk0fooRQpgDYjnEIrNZq9ZgAq+H5XjdDxhLb/UgDWS9pkISx58Z OJoJe7DX/JBJ30QeeFndL5VPxr8chTSVhAbfYG51dSTCJVV+3Z7+M2knRmnePAnr1C qQFbJ9COBhwMxGDPyOqCoh2lli4sjTb2ehpVQnOgET6VCxAHOsc4GwPVDEHNuYL/rT p8c/GAFunEfMfsCfPaMhgoowDq8gBPbhdd7mQ/CddjF76WlOvKSAXGLlUEPxTaSyCD VIhvw1ZtYQniyap1AcbLf8rdZYc+aqnhLSOXhvN/qfvEMS/B3DxOpJi5XHTTenkQSA VxKPJ+U2KmzZQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next v14 5/5] net: stmmac: rework stmmac_rx to support XDP rx multi-buff Reply-To: sashiko-reviews@lists.linux.dev To: "Lorenzo Bianconi" Cc: bpf@vger.kernel.org In-Reply-To: <20261204-stmmac-rx-mb-v14-5-5506796fd39e@oss.qualcomm.com> References: <20261204-stmmac-rx-mb-v14-0-5506796fd39e@oss.qualcomm.com> <20261204-stmmac-rx-mb-v14-5-5506796fd39e@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 10:45:46 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Low] net: stmmac: stmmac_rx() copies uninitialized ctx.xdp to state.xdp - [Low] net: stmmac: stale xdp_frags_truesize after xdp_buff_shrink_tail() -- commit 60febdab2a5f659e2de10ff9559c6cfd968ef63a Author: Lorenzo Bianconi net: stmmac: rework stmmac_rx to support XDP rx multi-buff This commit reworks stmmac_rx() to accumulate multi-descriptor and second-buffer frames into an xdp_buff before running the XDP program and building the skb with xdp_build_skb_from_buff(). It also stores the in-progress xdp_buff in rx_q->state across NAPI poll boundaries. > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/= net/ethernet/stmicro/stmmac/stmmac_main.c > index c429cb9e1ccbe..0edc92d5fb306 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c [ ... ] > @@ -5879,6 +5883,25 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, = int limit, u32 queue) > return failure ? limit : (int)count; > } > =20 > +static bool stmmac_build_xdp_frags(struct stmmac_priv *priv, > + struct stmmac_rx_queue *rx_q, > + unsigned int len, struct page *page, > + unsigned int offset, > + enum dma_data_direction dma_dir, > + struct xdp_buff *xdp) > +{ > + dma_addr_t dma_addr =3D page_pool_get_dma_addr(page) + offset; > + > + dma_sync_single_for_cpu(priv->device, dma_addr, len, dma_dir); > + if (!xdp_buff_add_frag(xdp, page_to_netmem(page), offset, len, > + xdp->frame_sz)) { > + page_pool_put_full_page(rx_q->page_pool, page, true); > + return false; > + } > + > + return true; > +} [Severity: Low] Can passing xdp->frame_sz to xdp_buff_add_frag() leave skb->truesize overstated after FCS stripping? xdp_buff_add_frag() accumulates xdp->frame_sz into sinfo->xdp_frags_truesize for every attached fragment. When a frame with two or more fragments has 1 to 4 trailing FCS bytes in its final fragment, stmmac_rx() calls xdp_buff_shrink_tail(&ctx.xdp, ETH_FCS_LEN) -> xdp_frags_shrink_tail(), which frees that fragment and updates sinfo->nr_frags and sinfo->xdp_frags_size, but leaves sinfo->xdp_frags_truesize unchanged. xdp_build_skb_from_buff() then prefers the stale non-zero sinfo->xdp_frags_truesize over nr_frags * xdp->frame_sz, overcharging skb->truesize by a full xdp->frame_sz allocation and slightly reducing effective socket receive buffer accounting. Passing 0 for truesize here would let xdp_build_skb_from_buff() compute nr_frags * xdp->frame_sz from the post-shrink fragment count, or xdp_frags_shrink_tail() could adjust sinfo->xdp_frags_truesize. [ ... ] > @@ -6138,21 +6110,28 @@ static int stmmac_rx(struct stmmac_priv *priv, in= t limit, u32 queue) > if (!stmmac_get_rx_hash(priv, p, &hash, &hash_type)) > skb_set_hash(skb, hash, hash_type); > =20 > - skb_record_rx_queue(skb, queue); > napi_gro_receive(&ch->rx_napi, skb); > rx_packets++; > rx_bytes +=3D len; > next: > in_progress =3D false; > - skb =3D NULL; > + n_descs =3D 0; > + count++; > + continue; > +error_free_frag: > + if (n_descs) > + __xdp_return_buff(&ctx.xdp, true); > + in_progress =3D false; > + n_descs =3D 0; > count++; > } > =20 > - if (in_progress || skb) { > - rx_q->state_saved =3D true; > - rx_q->state.skb =3D skb; > + if (in_progress || n_descs) { > + rx_q->state.xdp =3D ctx.xdp; > + rx_q->state.n_descs =3D n_descs; > rx_q->state.error =3D error; > rx_q->state.len =3D len; > + rx_q->state_saved =3D true; > } [Severity: Low] Can this copy uninitialized stack memory from ctx.xdp into rx_q->state.xdp? ctx is declared uninitialized on the stack in stmmac_rx(). On cores using enh_desc_get_rx_status() or ndesc_get_rx_status(), a first descriptor without RDES0_LAST_DESCRIPTOR returns discard_frame | rx_not_ls, so stmmac_rx() sets in_progress and error and jumps to read_again without initializing ctx.xdp, leaving n_descs at 0. If the next descriptor is still owned by DMA and the loop breaks, rx_q->state.xdp =3D ctx.xdp copies the uninitialized struct (and the next poll copies it back). Even when n_descs is non-zero, xdp_init_buff() and xdp_prepare_buff() leave ctx.xdp.txq uninitialized, so copying ctx.xdp by value still reads an uninitialized field. This can trigger KMSAN uninit-value reports or -Wmaybe-uninitialized warnings. Guarding the xdp save and restore with n_descs and zero-initializing ctx (or ctx.xdp.txq) would avoid both. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-stmmac-rx-= mb-v14-0-5506796fd39e@oss.qualcomm.com?part=3D5