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: <20230426064941.GF27649@unreal>
Date:   Wed, 26 Apr 2023 09:49:41 +0300
From:   Leon Romanovsky <leon@...nel.org>
To:     Tony Nguyen <anthony.l.nguyen@...el.com>
Cc:     davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com,
        edumazet@...gle.com, netdev@...r.kernel.org,
        Dawid Wesierski <dawidx.wesierski@...el.com>,
        Kamil Maziarz <kamil.maziarz@...el.com>,
        Jacob Keller <Jacob.e.keller@...el.com>,
        Rafal Romanowski <rafal.romanowski@...el.com>
Subject: Re: [PATCH net 2/3] ice: Fix ice VF reset during iavf initialization

On Tue, Apr 25, 2023 at 10:01:26AM -0700, Tony Nguyen wrote:
> From: Dawid Wesierski <dawidx.wesierski@...el.com>
> 
> Fix the current implementation that causes ice_trigger_vf_reset()
> to start resetting the VF even when the VF is still resetting itself
> and initializing adminq. This leads to a series of -53 errors
> (failed to init adminq) from the IAVF.
> 
> Change the state of the vf_state field to be not active when the IAVF
> asks for a reset. To avoid issues caused by the VF being reset too
> early, make sure to wait until receiving the message on the message
> box to know the exact state of the IAVF driver.
> 
> Fixes: c54d209c78b8 ("ice: Wait for VF to be reset/ready before configuration")
> Signed-off-by: Dawid Wesierski <dawidx.wesierski@...el.com>
> Signed-off-by: Kamil Maziarz <kamil.maziarz@...el.com>
> Acked-by: Jacob Keller <Jacob.e.keller@...el.com>
> Tested-by: Rafal Romanowski <rafal.romanowski@...el.com>
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@...el.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_sriov.c    |  8 ++++----
>  drivers/net/ethernet/intel/ice/ice_vf_lib.c   | 19 +++++++++++++++++++
>  drivers/net/ethernet/intel/ice/ice_vf_lib.h   |  1 +
>  drivers/net/ethernet/intel/ice/ice_virtchnl.c |  1 +
>  4 files changed, 25 insertions(+), 4 deletions(-)

<...>

> -	ret = ice_check_vf_ready_for_cfg(vf);
> +	ret = ice_check_vf_ready_for_reset(vf);
>  	if (ret)
>  		goto out_put_vf;

<...>

> +/**
> + * ice_check_vf_ready_for_reset - check if VF is ready to be reset
> + * @vf: VF to check if it's ready to be reset
> + *
> + * The purpose of this function is to ensure that the VF is not in reset,
> + * disabled, and is both initialized and active, thus enabling us to safely
> + * initialize another reset.
> + */
> +int ice_check_vf_ready_for_reset(struct ice_vf *vf)
> +{
> +	int ret;
> +
> +	ret = ice_check_vf_ready_for_cfg(vf);
> +	if (!ret && !test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states))
> +		ret = -EAGAIN;

I don't know your driver enough to say how it is it possible to find VF
"resetting itself" and PF trying to reset VF at the same time.

But what I see is that ICE_VF_STATE_ACTIVE bit check is racy and you
don't really fix the root cause of calling to reset without proper locking.

Thanks

> +
> +	return ret;
> +}

<...>

>  	case VIRTCHNL_OP_RESET_VF:
> +		clear_bit(ICE_VF_STATE_ACTIVE, vf->vf_states);
>  		ops->reset_vf(vf);
>  		break;
>  	case VIRTCHNL_OP_ADD_ETH_ADDR:
> -- 
> 2.38.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ