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: <IA3PR11MB8986D6452E1EC4A7834A8641E5CAA@IA3PR11MB8986.namprd11.prod.outlook.com>
Date: Fri, 14 Nov 2025 19:24:46 +0000
From: "Loktionov, Aleksandr" <aleksandr.loktionov@...el.com>
To: "gregory.herrero@...cle.com" <gregory.herrero@...cle.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>
CC: "intel-wired-lan@...ts.osuosl.org" <intel-wired-lan@...ts.osuosl.org>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v3 1/1] i40e: validate ring_len parameter against
 hardware-specific values



> -----Original Message-----
> From: gregory.herrero@...cle.com <gregory.herrero@...cle.com>
> Sent: Friday, November 14, 2025 5:03 PM
> To: Loktionov, Aleksandr <aleksandr.loktionov@...el.com>; 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
> Cc: intel-wired-lan@...ts.osuosl.org; netdev@...r.kernel.org; linux-
> kernel@...r.kernel.org; Gregory Herrero <gregory.herrero@...cle.com>
> Subject: [PATCH v3 1/1] i40e: validate ring_len parameter against
> hardware-specific values
> 
> From: Gregory Herrero <gregory.herrero@...cle.com>
> 
> The maximum number of descriptors supported by the hardware is
> hardware dependent and can be retrieved using
> i40e_get_max_num_descriptors().
> Move this function to a shared header and use it when checking for
> valid ring_len parameter rather than using hardcoded value.
> Cast info->ring_len to u32 in i40e_config_vsi_tx_queue() as it's u16
> in struct virtchnl_txq_info.
> 
> By fixing an over-acceptance issue, behavior change could be seen
> where ring_len could now be rejected while configuring rx and tx
> queues if its size is larger than the hardware-specific maximum number
> of descriptors.
> 
> Fixes: 55d225670def ("i40e: add validation for ring_len param")
> Signed-off-by: Gregory Herrero <gregory.herrero@...cle.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e.h          | 17
> +++++++++++++++++
>  drivers/net/ethernet/intel/i40e/i40e_ethtool.c  | 12 ------------
> .../net/ethernet/intel/i40e/i40e_virtchnl_pf.c  |  4 ++--
>  3 files changed, 19 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e.h
> b/drivers/net/ethernet/intel/i40e/i40e.h
> index 801a57a925da..a953cce008f4 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e.h
> +++ b/drivers/net/ethernet/intel/i40e/i40e.h
> @@ -1418,4 +1418,21 @@ static inline struct i40e_veb
> *i40e_pf_get_main_veb(struct i40e_pf *pf)
>  	return (pf->lan_veb != I40E_NO_VEB) ? pf->veb[pf->lan_veb] :
> NULL;  }
> 
> +/**
> + * i40e_get_max_num_descriptors - get maximum number of descriptors
> for this hardware.
Please wrap this line to keep within ~80 columns (which is still enforced in net/* reviews and expected for drivers/net as well).

> + * @pf: pointer to a PF
> + *
> + * Return: u32 value corresponding to the maximum number of
> descriptors.
> + **/
> +static inline u32 i40e_get_max_num_descriptors(const struct i40e_pf
> +*pf) {
> +	const struct i40e_hw *hw = &pf->hw;
> +
> +	switch (hw->mac.type) {
> +	case I40E_MAC_XL710:
> +		return I40E_MAX_NUM_DESCRIPTORS_XL710;
> +	default:
> +		return I40E_MAX_NUM_DESCRIPTORS;
> +	}
> +}
>  #endif /* _I40E_H_ */
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> index 86c72596617a..61c39e881b00 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> @@ -2013,18 +2013,6 @@ static void i40e_get_drvinfo(struct net_device
> *netdev,
>  		drvinfo->n_priv_flags += I40E_GL_PRIV_FLAGS_STR_LEN;  }
> 
> -static u32 i40e_get_max_num_descriptors(struct i40e_pf *pf) -{
> -	struct i40e_hw *hw = &pf->hw;
> -
> -	switch (hw->mac.type) {
> -	case I40E_MAC_XL710:
> -		return I40E_MAX_NUM_DESCRIPTORS_XL710;
> -	default:
> -		return I40E_MAX_NUM_DESCRIPTORS;
> -	}
> -}
> -
>  static void i40e_get_ringparam(struct net_device *netdev,
>  			       struct ethtool_ringparam *ring,
>  			       struct kernel_ethtool_ringparam
> *kernel_ring, diff --git
> a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> index 081a4526a2f0..5ecc9bb908f9 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> @@ -656,7 +656,7 @@ static int i40e_config_vsi_tx_queue(struct i40e_vf
> *vf, u16 vsi_id,
> 
>  	/* ring_len has to be multiple of 8 */
>  	if (!IS_ALIGNED(info->ring_len, 8) ||
> -	    info->ring_len > I40E_MAX_NUM_DESCRIPTORS_XL710) {
> +	    (u32)info->ring_len > i40e_get_max_num_descriptors(pf)) {
The cast to u32 is not needed: info->ring_len (per your commit message, u16 in struct virtchnl_txq_info) will undergo the usual integer promotions and be compared as u32 against the function's u32 return value. Dropping the cast reduces churn and matches the RX path style (which doesn't cast)

>  		ret = -EINVAL;
>  		goto error_context;
>  	}
> @@ -726,7 +726,7 @@ static int i40e_config_vsi_rx_queue(struct i40e_vf
> *vf, u16 vsi_id,
> 
>  	/* ring_len has to be multiple of 32 */
>  	if (!IS_ALIGNED(info->ring_len, 32) ||
> -	    info->ring_len > I40E_MAX_NUM_DESCRIPTORS_XL710) {
> +	    info->ring_len > i40e_get_max_num_descriptors(pf)) {
>  		ret = -EINVAL;
>  		goto error_param;
>  	}
> --
> 2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ