Skip to content

Commit 39707da

Browse files
pvts-matPlaidCat
authored andcommitted
i40e: validate ring_len parameter against hardware-specific values
jira VULN-158762 cve-bf CVE-2025-39973 commit-author Gregory Herrero <gregory.herrero@oracle.com> commit 6994283 upstream-diff Context conflict resolved in drivers/net/ethernet/intel/i40e/i40e.h 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. 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-dependent maximum number of descriptors. Fixes: 55d2256 ("i40e: add validation for ring_len param") Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> (cherry picked from commit 6994283) Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>
1 parent dfd129e commit 39707da

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

drivers/net/ethernet/intel/i40e/i40e.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,4 +1109,16 @@ int i40e_add_del_cloud_filter(struct i40e_vsi *vsi,
11091109
int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi,
11101110
struct i40e_cloud_filter *filter,
11111111
bool add);
1112+
1113+
static inline u32 i40e_get_max_num_descriptors(const struct i40e_pf *pf)
1114+
{
1115+
const struct i40e_hw *hw = &pf->hw;
1116+
1117+
switch (hw->mac.type) {
1118+
case I40E_MAC_XL710:
1119+
return I40E_MAX_NUM_DESCRIPTORS_XL710;
1120+
default:
1121+
return I40E_MAX_NUM_DESCRIPTORS;
1122+
}
1123+
}
11121124
#endif /* _I40E_H_ */

drivers/net/ethernet/intel/i40e/i40e_ethtool.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,18 +1904,6 @@ static void i40e_get_drvinfo(struct net_device *netdev,
19041904
drvinfo->n_priv_flags += I40E_GL_PRIV_FLAGS_STR_LEN;
19051905
}
19061906

1907-
static u32 i40e_get_max_num_descriptors(struct i40e_pf *pf)
1908-
{
1909-
struct i40e_hw *hw = &pf->hw;
1910-
1911-
switch (hw->mac.type) {
1912-
case I40E_MAC_XL710:
1913-
return I40E_MAX_NUM_DESCRIPTORS_XL710;
1914-
default:
1915-
return I40E_MAX_NUM_DESCRIPTORS;
1916-
}
1917-
}
1918-
19191907
static void i40e_get_ringparam(struct net_device *netdev,
19201908
struct ethtool_ringparam *ring)
19211909
{

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ static int i40e_config_vsi_tx_queue(struct i40e_vf *vf, u16 vsi_id,
565565

566566
/* ring_len has to be multiple of 8 */
567567
if (!IS_ALIGNED(info->ring_len, 8) ||
568-
info->ring_len > I40E_MAX_NUM_DESCRIPTORS_XL710) {
568+
info->ring_len > i40e_get_max_num_descriptors(pf)) {
569569
ret = -EINVAL;
570570
goto error_context;
571571
}
@@ -638,7 +638,7 @@ static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_id,
638638

639639
/* ring_len has to be multiple of 32 */
640640
if (!IS_ALIGNED(info->ring_len, 32) ||
641-
info->ring_len > I40E_MAX_NUM_DESCRIPTORS_XL710) {
641+
info->ring_len > i40e_get_max_num_descriptors(pf)) {
642642
ret = -EINVAL;
643643
goto error_param;
644644
}

0 commit comments

Comments
 (0)