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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <PH3PPF7A88A980A42000BD3AE75C833BD6FE55CA@PH3PPF7A88A980A.namprd11.prod.outlook.com>
Date: Tue, 22 Jul 2025 15:03:15 +0000
From: "Loktionov, Aleksandr" <aleksandr.loktionov@...el.com>
To: Jason Xing <kerneljasonxing@...il.com>, "Nguyen, Anthony L"
	<anthony.l.nguyen@...el.com>, "Kitszel, Przemyslaw"
	<przemyslaw.kitszel@...el.com>, "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>,
	"bjorn@...nel.org" <bjorn@...nel.org>, "Karlsson, Magnus"
	<magnus.karlsson@...el.com>, "Fijalkowski, Maciej"
	<maciej.fijalkowski@...el.com>, "jonathan.lemon@...il.com"
	<jonathan.lemon@...il.com>, "sdf@...ichev.me" <sdf@...ichev.me>,
	"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>,
	"mcoquelin.stm32@...il.com" <mcoquelin.stm32@...il.com>,
	"alexandre.torgue@...s.st.com" <alexandre.torgue@...s.st.com>
CC: "linux-stm32@...md-mailman.stormreply.com"
	<linux-stm32@...md-mailman.stormreply.com>, "bpf@...r.kernel.org"
	<bpf@...r.kernel.org>, "intel-wired-lan@...ts.osuosl.org"
	<intel-wired-lan@...ts.osuosl.org>, "netdev@...r.kernel.org"
	<netdev@...r.kernel.org>, Jason Xing <kernelxing@...cent.com>
Subject: RE: [Intel-wired-lan] [PATCH net v2 2/2] igb: xsk: solve underflow of
 nb_pkts in zerocopy mode



> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@...osl.org> On Behalf
> Of Jason Xing
> Sent: Tuesday, July 22, 2025 3:51 PM
> To: Nguyen, Anthony L <anthony.l.nguyen@...el.com>; Kitszel,
> Przemyslaw <przemyslaw.kitszel@...el.com>; andrew+netdev@...n.ch;
> davem@...emloft.net; edumazet@...gle.com; kuba@...nel.org;
> pabeni@...hat.com; bjorn@...nel.org; Karlsson, Magnus
> <magnus.karlsson@...el.com>; Fijalkowski, Maciej
> <maciej.fijalkowski@...el.com>; jonathan.lemon@...il.com;
> sdf@...ichev.me; ast@...nel.org; daniel@...earbox.net;
> hawk@...nel.org; john.fastabend@...il.com; mcoquelin.stm32@...il.com;
> alexandre.torgue@...s.st.com
> Cc: linux-stm32@...md-mailman.stormreply.com; bpf@...r.kernel.org;
> intel-wired-lan@...ts.osuosl.org; netdev@...r.kernel.org; Jason Xing
> <kernelxing@...cent.com>
> Subject: [Intel-wired-lan] [PATCH net v2 2/2] igb: xsk: solve
> underflow of nb_pkts in zerocopy mode
> 
> From: Jason Xing <kernelxing@...cent.com>
> 
> There is no break time in the while() loop, so every time at the end
> of igb_xmit_zc(), underflow of nb_pkts will occur, which renders the
> return value always false. But theoretically, the result should be set
> after calling xsk_tx_peek_release_desc_batch(). We can take
> i40e_xmit_zc() as a good example.
> 
> Returning false means we're not done with transmission and we need one
> more poll, which is exactly what igb_xmit_zc() always did before this
> patch. After this patch, the return value depends on the nb_pkts
> value.
> Two cases might happen then:
> 1. if (nb_pkts < budget), it means we process all the possible data,
> so
>    return true and no more necessary poll will be triggered because of
>    this.
> 2. if (nb_pkts == budget), it means we might have more data, so return
>    false to let another poll run again.
> 
> Fixes: f8e284a02afc ("igb: Add AF_XDP zero-copy Tx support")
> Signed-off-by: Jason Xing <kernelxing@...cent.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@...el.com>
> ---
> v2
> Link: https://lore.kernel.org/all/20250721083343.16482-1-
> kerneljasonxing@...il.com/
> 1. target net tree instead of net-next
> 2. use for loop instead
> ---
>  drivers/net/ethernet/intel/igb/igb_xsk.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c
> b/drivers/net/ethernet/intel/igb/igb_xsk.c
> index 5cf67ba29269..30ce5fbb5b77 100644
> --- a/drivers/net/ethernet/intel/igb/igb_xsk.c
> +++ b/drivers/net/ethernet/intel/igb/igb_xsk.c
> @@ -482,7 +482,7 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct
> xsk_buff_pool *xsk_pool)
>  	if (!nb_pkts)
>  		return true;
> 
> -	while (nb_pkts-- > 0) {
> +	for (; i < nb_pkts; i++) {
>  		dma = xsk_buff_raw_get_dma(xsk_pool, descs[i].addr);
>  		xsk_buff_raw_dma_sync_for_device(xsk_pool, dma,
> descs[i].len);
> 
> @@ -512,7 +512,6 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct
> xsk_buff_pool *xsk_pool)
> 
>  		total_bytes += descs[i].len;
> 
> -		i++;
>  		tx_ring->next_to_use++;
>  		tx_buffer_info->next_to_watch = tx_desc;
>  		if (tx_ring->next_to_use == tx_ring->count)
> --
> 2.41.3


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ