From nobody Sun Feb 8 09:12:32 2026 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E221B32D451; Fri, 14 Nov 2025 16:03:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763136219; cv=none; b=S8cRphtroBojmoVVs7Byhf5ZYmLr3jdxgIS6Ye9wKPptpXOKf401Gu3aJSQkyopZzKGJRQvTs4TnbWkv1k/EaYQQhJG9vCUmFJh0vHxD3n6n2XqaAJI5Xc7KkHSKfQ68MVSyUUZ5t1LRY5ToFm2q5LwheWIJLXBdda0HJ2wayRs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763136219; c=relaxed/simple; bh=rmkhoRbEEjrqjUQFnPQrRVoPpVLyPa0GUmQZOxDpO4g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FX0diOV7CjPLouuLW+Zie0K0RLob+N8NttY/8T1kz18rt3QfLZ31wM7BFj3sWuV42Hb+VNvjDDFexTKhBH5snsdeBq5FUry5ssOUjz9Z7+ZefzPVLBvpvaWCZ2lCFCmRruh8diUtB2lPwN551RERxXBTtuOAi0JiRDp14C3zdDg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=G24IlMxM; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="G24IlMxM" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5AECuFdI000348; Fri, 14 Nov 2025 16:03:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=bte06 RvP1Ns3uJUbnsCYNwVEAvBdal+RTPg/GP86gGU=; b=G24IlMxMxLaydliB0hUlF 6KKP9cmuZr+NSd7HptSQstJt49HMcJL6wOTEnVE4bsjcD72c3sWXrotypeV/sIzZ pvFO52bBQQzplparMYw7jEPKWOx+ciuXXC8Ohzljn8orTgT/pCOHFv271jYtPSs4 XXlZxwUC7AGw+KGI3bUn3i79kASTDkuhcFCPb3h1X2/Oc65LYVO8EovTsqvjYP1f YiXYrMo9U18Fvv9wedDAxW4H5wPJAd++3jB9jsagDtzKnFAUr/HVYE93EiNitNSM VFPQnb2SBI132FWv7bXkbEv76zLN0/OwHUKrIt5VwA+fditOgXGUopA//kHd2zo9 A== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4adr8uhdy7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Nov 2025 16:03:28 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 5AEEYTWu022109; Fri, 14 Nov 2025 16:03:27 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4a9vadpv9b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Nov 2025 16:03:27 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 5AEG3IZD029266; Fri, 14 Nov 2025 16:03:27 GMT Received: from oracle (dhcp-10-154-173-166.vpn.oracle.com [10.154.173.166]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4a9vadpv0s-2; Fri, 14 Nov 2025 16:03:26 +0000 From: gregory.herrero@oracle.com To: aleksandr.loktionov@intel.com, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Gregory Herrero Subject: [PATCH v3 1/1] i40e: validate ring_len parameter against hardware-specific values Date: Fri, 14 Nov 2025 17:03:04 +0100 Message-ID: <20251114160304.2576306-2-gregory.herrero@oracle.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251114160304.2576306-1-gregory.herrero@oracle.com> References: <20251114160304.2576306-1-gregory.herrero@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-14_04,2025-11-13_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2511140129 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTEzMDE3OCBTYWx0ZWRfX8OMqO2mhG4Fa zsKtH5bI9Dq/Jy4eDfczc/o8RoT7kIwnYwuhAxN0ZHCobL1ohdfdSTMmjZGE+6lUPXGIBhJgiFh RNwPGd6U4V9P1pfyvzDNlkdCIF6D4G3zh6PrmgtQUG4I/PqThyxFzCwNl5WqJGzXCTUssU99w8w 9mdGU++6VUUUML3MwEdehrYcySBixAC4OgO4drVL6Nuymw+10DSFFcnqsLF/Ko58huTE+NgIgJK pf1hVJR2XyO8dmBwF49zaAime183ZCfXnjaAIRngwMsRLjouybMEuZ2EV3O4NmhQGVvM2Nj8157 iM/xAviIJKTRy7WpXWwJTE6DB4JhA/IHi9FcKZGblGnjiBRgrdzVDwmflWxXnTVtcL0xUKzXOsV qNcogqgUJkiWYoRwzfN6t2G7X9/emQ== X-Proofpoint-ORIG-GUID: BUMw4X2x_zQxi5VwPb3LmPctTwbwx19T X-Authority-Analysis: v=2.4 cv=FKAWBuos c=1 sm=1 tr=0 ts=691752d0 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=9o2BAfuAlkXtMw4cUEAA:9 X-Proofpoint-GUID: BUMw4X2x_zQxi5VwPb3LmPctTwbwx19T Content-Type: text/plain; charset="utf-8" From: Gregory Herrero 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 --- 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 !=3D I40E_NO_VEB) ? pf->veb[pf->lan_veb] : NULL; } =20 +/** + * i40e_get_max_num_descriptors - get maximum number of descriptors for th= is hardware. + * @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 =3D &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/e= thernet/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 *netd= ev, drvinfo->n_priv_flags +=3D I40E_GL_PRIV_FLAGS_STR_LEN; } =20 -static u32 i40e_get_max_num_descriptors(struct i40e_pf *pf) -{ - struct i40e_hw *hw =3D &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/n= et/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, =20 /* 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)) { ret =3D -EINVAL; goto error_context; } @@ -726,7 +726,7 @@ static int i40e_config_vsi_rx_queue(struct i40e_vf *vf,= u16 vsi_id, =20 /* 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 =3D -EINVAL; goto error_param; } --=20 2.51.0