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] [thread-next>] [day] [month] [year] [list]
Message-ID: <c3fc2a72a567e26613824001324bcac6fc8c3640.camel@gmail.com>
Date:   Thu, 09 Feb 2023 09:07:42 -0800
From:   Alexander H Duyck <alexander.duyck@...il.com>
To:     Larysa Zaremba <larysa.zaremba@...el.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Eric Dumazet <edumazet@...gle.com>,
        Paolo Abeni <pabeni@...hat.com>
Cc:     intel-wired-lan@...osl.org, netdev@...r.kernel.org,
        bpf@...r.kernel.org,
        Alexander Lobakin <alexandr.lobakin@...el.com>,
        Tony Nguyen <anthony.l.nguyen@...el.com>,
        Maciej Fijalkowski <maciej.fijalkowski@...el.com>
Subject: Re: [PATCH net] ice: xsk: Fix cleaning of XDP_TX frames

On Thu, 2023-02-09 at 17:01 +0100, Larysa Zaremba wrote:
> Incrementation of xsk_frames inside the for-loop produces
> infinite loop, if we have both normal AF_XDP-TX and XDP_TXed
> buffers to complete.
> 
> Split xsk_frames into 2 variables (xsk_frames and completed_frames)
> to eliminate this bug.
> 
> Fixes: 29322791bc8b ("ice: xsk: change batched Tx descriptor cleaning")
> Acked-by: Maciej Fijalkowski <maciej.fijalkowski@...el.com>
> Signed-off-by: Larysa Zaremba <larysa.zaremba@...el.com>
> ---
> To Tony: this is urgent and should go directly via net. It's tested and acked.
> ---
>  drivers/net/ethernet/intel/ice/ice_xsk.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
> index 7105de6fb344..374b7f10b549 100644
> --- a/drivers/net/ethernet/intel/ice/ice_xsk.c
> +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
> @@ -800,6 +800,7 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
>  	struct ice_tx_desc *tx_desc;
>  	u16 cnt = xdp_ring->count;
>  	struct ice_tx_buf *tx_buf;
> +	u16 completed_frames = 0;
>  	u16 xsk_frames = 0;
>  	u16 last_rs;
>  	int i;
> @@ -809,19 +810,21 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
>  	if ((tx_desc->cmd_type_offset_bsz &
>  	    cpu_to_le64(ICE_TX_DESC_DTYPE_DESC_DONE))) {
>  		if (last_rs >= ntc)
> -			xsk_frames = last_rs - ntc + 1;
> +			completed_frames = last_rs - ntc + 1;
>  		else
> -			xsk_frames = last_rs + cnt - ntc + 1;
> +			completed_frames = last_rs + cnt - ntc + 1;
>  	}
>  
> -	if (!xsk_frames)
> +	if (!completed_frames)
>  		return;
>  
> -	if (likely(!xdp_ring->xdp_tx_active))
> +	if (likely(!xdp_ring->xdp_tx_active)) {
> +		xsk_frames = completed_frames;
>  		goto skip;
> +	}
>  
>  	ntc = xdp_ring->next_to_clean;
> -	for (i = 0; i < xsk_frames; i++) {
> +	for (i = 0; i < completed_frames; i++) {
>  		tx_buf = &xdp_ring->tx_buf[ntc];
>  
>  		if (tx_buf->raw_buf) {
> @@ -837,7 +840,7 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
>  	}
>  skip:
>  	tx_desc->cmd_type_offset_bsz = 0;
> -	xdp_ring->next_to_clean += xsk_frames;
> +	xdp_ring->next_to_clean += completed_frames;
>  	if (xdp_ring->next_to_clean >= cnt)
>  		xdp_ring->next_to_clean -= cnt;
>  	if (xsk_frames)

Looks good to me.

Reviewed-by: Alexander Duyck <alexanderduyck@...com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ