lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
 <PAXPR04MB8510499B65301187736D511088A8A@PAXPR04MB8510.eurprd04.prod.outlook.com>
Date: Thu, 18 Dec 2025 06:36:47 +0000
From: Wei Fang <wei.fang@....com>
To: Hariprasad Kelam <hkelam@...vell.com>
CC: "andrew+netdev@...n.ch" <andrew+netdev@...n.ch>, "davem@...emloft.net"
	<davem@...emloft.net>, "edumazet@...gle.com" <edumazet@...gle.com>,
	"kuba@...nel.org" <kuba@...nel.org>, "pabeni@...hat.com" <pabeni@...hat.com>,
	"mcoquelin.stm32@...il.com" <mcoquelin.stm32@...il.com>,
	"alexandre.torgue@...s.st.com" <alexandre.torgue@...s.st.com>,
	"ast@...nel.org" <ast@...nel.org>, "daniel@...earbox.net"
	<daniel@...earbox.net>, "hawk@...nel.org" <hawk@...nel.org>,
	"john.fastabend@...il.com" <john.fastabend@...il.com>, "sdf@...ichev.me"
	<sdf@...ichev.me>, "rmk+kernel@...linux.org.uk" <rmk+kernel@...linux.org.uk>,
	"0x1207@...il.com" <0x1207@...il.com>, "hayashi.kunihiko@...ionext.com"
	<hayashi.kunihiko@...ionext.com>, Vladimir Oltean <vladimir.oltean@....com>,
	"boon.leong.ong@...el.com" <boon.leong.ong@...el.com>, "imx@...ts.linux.dev"
	<imx@...ts.linux.dev>, "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-stm32@...md-mailman.stormreply.com"
	<linux-stm32@...md-mailman.stormreply.com>,
	"linux-arm-kernel@...ts.infradead.org"
	<linux-arm-kernel@...ts.infradead.org>, "bpf@...r.kernel.org"
	<bpf@...r.kernel.org>
Subject: RE: [PATCH net] net: stmmac: fix the crash issue for zero copy XDP_TX
 action

> On 2025-12-17 at 18:19:19, Wei Fang (wei.fang@....com) wrote:
> > > > -	res = stmmac_xdp_xmit_xdpf(priv, queue, xdpf, false);
> > > > -	if (res == STMMAC_XDP_TX)
> > > > +	/* For zero copy XDP_TX action, dma_map is true */
> > > > +	res = stmmac_xdp_xmit_xdpf(priv, queue, xdpf, zc);
> > > 	Seems stmmac_xdp_xmit_xdpf is using dma_map_single if we pass zc is
> > > true.
> > >         Ideally in case of zc, driver can use
> > > page_pool_get_dma_addr, may be you
> > >         need pass zc param as false. Please check
> > >
> >
> > No, the memory type of xdpf->data is MEM_TYPE_PAGE_ORDER0 rather than
> > MEM_TYPE_PAGE_POOL, so we should use dma_map_single().
> > Otherwise, it will lead to invalid mappings and cause the crash.
> >
> >
>  ACK, found below code bit confusing
> 		case STMMAC_XDP_CONSUMED:
>  			xsk_buff_free(buf->xdp);
> +			fallthrough;
> +		case STMMAC_XSK_CONSUMED:
>  			rx_dropped++;
> 
>      Ideally in case of STMMAC_XSK_CONSUMED, driver needs to call
> xsk_buff_free.
>      And in case of STMMAC_XDP_CONSUMED, driver needs to call
> xdp_return_frame.
>      May be you can move all buffer free logic to stmmac_rx_zc with above
> suggested
>      changes.

For zero copy, the xdp_buff is freed by xdp_convert_buff_to_frame()
when converting the xdp_xdp to xdp_frame. So STMMAC_XSK_CONSUMED
means the xdp_buff has been freed, it tells stmmac_rx_zc() no to free a
xdp_buff that has been freed.

I have added a comment for STMMAC_XSK_CONSUMED, see

+       } else if (res == STMMAC_XDP_CONSUMED && zc) {
+               /* xdp has been freed by xdp_convert_buff_to_frame(),
+                * no need to call xsk_buff_free() again, so return
+                * STMMAC_XSK_CONSUMED.
+                */
+               res = STMMAC_XSK_CONSUMED;
+               xdp_return_frame(xdpf);
+       }


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ