From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CDAA7A0A02 for ; Mon, 17 May 2021 18:14:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C74F0410EA; Mon, 17 May 2021 18:14:07 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id BDF3F410E0 for ; Mon, 17 May 2021 18:14:06 +0200 (CEST) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=Keschdeichel.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lifsa-00081d-Hq; Mon, 17 May 2021 16:14:04 +0000 From: Christian Ehrhardt To: Chengchang Tang Cc: Min Hu , Ferruh Yigit , dpdk stable Date: Mon, 17 May 2021 18:08:38 +0200 Message-Id: <20210517161039.3132619-89-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517161039.3132619-1-christian.ehrhardt@canonical.com> References: <20210517161039.3132619-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'ethdev: validate input in module EEPROM dump' has been queued to stable release 19.11.9 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/19/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/d50e609bde4d36b56e794701018c15d90027821a Thanks. Christian Ehrhardt --- >From d50e609bde4d36b56e794701018c15d90027821a Mon Sep 17 00:00:00 2001 From: Chengchang Tang Date: Fri, 2 Apr 2021 10:58:48 +0800 Subject: [PATCH] ethdev: validate input in module EEPROM dump [ upstream commit e2bd08d569d9821131d8e245446d24eaed145f21 ] The validity verification of input parameters should be performed at API layer, not in the PMD. Fixes: 3a18c44b45df ("ethdev: add access to EEPROM") Fixes: 40ff8b305ab8 ("net/e1000: add module EEPROM callbacks for e1000") Fixes: f2088e785cca ("net/i40e: fix dereference before check when getting EEPROM") Fixes: b74d0cd43e37 ("net/ixgbe: add module EEPROM callbacks for ixgbe") Fixes: 8a6a09f853a0 ("net/mlx5: support reading module EEPROM data") Fixes: 58f6f93c34c1 ("net/octeontx2: add module EEPROM dump") Signed-off-by: Chengchang Tang Signed-off-by: Min Hu (Connor) Reviewed-by: Ferruh Yigit --- drivers/net/e1000/igb_ethdev.c | 3 --- drivers/net/i40e/i40e_ethdev.c | 3 --- drivers/net/ixgbe/ixgbe_ethdev.c | 3 --- drivers/net/mlx5/mlx5_ethdev.c | 4 ++-- drivers/net/octeontx2/otx2_ethdev_ops.c | 3 +-- lib/librte_ethdev/rte_ethdev.c | 4 ++++ lib/librte_ethdev/rte_ethdev.h | 2 ++ 7 files changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index a82209e6d9..06ba55b875 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -5518,9 +5518,6 @@ eth_igb_get_module_eeprom(struct rte_eth_dev *dev, u16 first_word, last_word; int i = 0; - if (info->length == 0) - return -EINVAL; - first_word = info->offset >> 1; last_word = (info->offset + info->length - 1) >> 1; diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 79558c8aad..b583d3a0ea 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -12129,9 +12129,6 @@ static int i40e_get_module_eeprom(struct rte_eth_dev *dev, uint32_t value = 0; uint32_t i; - if (!info || !info->length || !info->data) - return -EINVAL; - if (hw->phy.link_info.module_type[0] == I40E_MODULE_TYPE_SFP) is_sfp = true; diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index e7ddb237b1..9cb25bbf3a 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -7628,9 +7628,6 @@ ixgbe_get_module_eeprom(struct rte_eth_dev *dev, uint8_t *data = info->data; uint32_t i = 0; - if (info->length == 0) - return -EINVAL; - for (i = info->offset; i < info->offset + info->length; i++) { if (i < RTE_ETH_MODULE_SFF_8079_LEN) status = hw->phy.ops.read_i2c_eeprom(hw, i, &databyte); diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index efcc69ca44..7af7fb0f9f 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -1883,7 +1883,7 @@ mlx5_get_module_info(struct rte_eth_dev *dev, }; int ret = 0; - if (!dev || !modinfo) { + if (!dev) { DRV_LOG(WARNING, "missing argument, cannot get module info"); rte_errno = EINVAL; return -rte_errno; @@ -1917,7 +1917,7 @@ int mlx5_get_module_eeprom(struct rte_eth_dev *dev, struct ifreq ifr; int ret = 0; - if (!dev || !info) { + if (!dev) { DRV_LOG(WARNING, "missing argument, cannot get module eeprom"); rte_errno = EINVAL; return -rte_errno; diff --git a/drivers/net/octeontx2/otx2_ethdev_ops.c b/drivers/net/octeontx2/otx2_ethdev_ops.c index beb4f58148..1f8292589c 100644 --- a/drivers/net/octeontx2/otx2_ethdev_ops.c +++ b/drivers/net/octeontx2/otx2_ethdev_ops.c @@ -533,8 +533,7 @@ otx2_nix_get_module_eeprom(struct rte_eth_dev *eth_dev, struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); struct cgx_fw_data *rsp; - if (!info->data || !info->length || - (info->offset + info->length > SFP_EEPROM_SIZE)) + if (info->offset + info->length > SFP_EEPROM_SIZE) return -EINVAL; rsp = nix_get_fwdata(dev); diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index fb0912a4a8..14f9a7134c 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -4922,6 +4922,8 @@ rte_eth_dev_get_module_info(uint16_t port_id, struct rte_eth_dev *dev; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + if (modinfo == NULL) + return -EINVAL; dev = &rte_eth_devices[port_id]; RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_module_info, -ENOTSUP); @@ -4935,6 +4937,8 @@ rte_eth_dev_get_module_eeprom(uint16_t port_id, struct rte_eth_dev *dev; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + if (info == NULL || info->data == NULL || info->length == 0) + return -EINVAL; dev = &rte_eth_devices[port_id]; RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_module_eeprom, -ENOTSUP); diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 017459e595..8fd7f272bf 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -3920,6 +3920,7 @@ int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info); * - (0) if successful. * - (-ENOTSUP) if hardware doesn't support. * - (-ENODEV) if *port_id* invalid. + * - (-EINVAL) if bad parameter. * - (-EIO) if device is removed. * - others depends on the specific operations implementation. */ @@ -3942,6 +3943,7 @@ rte_eth_dev_get_module_info(uint16_t port_id, * @return * - (0) if successful. * - (-ENOTSUP) if hardware doesn't support. + * - (-EINVAL) if bad parameter. * - (-ENODEV) if *port_id* invalid. * - (-EIO) if device is removed. * - others depends on the specific operations implementation. -- 2.31.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-05-17 17:40:32.978052717 +0200 +++ 0089-ethdev-validate-input-in-module-EEPROM-dump.patch 2021-05-17 17:40:29.287810389 +0200 @@ -1 +1 @@ -From e2bd08d569d9821131d8e245446d24eaed145f21 Mon Sep 17 00:00:00 2001 +From d50e609bde4d36b56e794701018c15d90027821a Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit e2bd08d569d9821131d8e245446d24eaed145f21 ] + @@ -15 +16,0 @@ -Cc: stable@dpdk.org @@ -24 +25 @@ - drivers/net/mlx5/linux/mlx5_ethdev_os.c | 4 ++-- + drivers/net/mlx5/mlx5_ethdev.c | 4 ++-- @@ -31 +32 @@ -index 25218da240..7d6d04abcb 100644 +index a82209e6d9..06ba55b875 100644 @@ -34 +35 @@ -@@ -5118,9 +5118,6 @@ eth_igb_get_module_eeprom(struct rte_eth_dev *dev, +@@ -5518,9 +5518,6 @@ eth_igb_get_module_eeprom(struct rte_eth_dev *dev, @@ -45 +46 @@ -index 2076717324..c03e4a0a4b 100644 +index 79558c8aad..b583d3a0ea 100644 @@ -48 +49 @@ -@@ -11659,9 +11659,6 @@ static int i40e_get_module_eeprom(struct rte_eth_dev *dev, +@@ -12129,9 +12129,6 @@ static int i40e_get_module_eeprom(struct rte_eth_dev *dev, @@ -59 +60 @@ -index 2d308be48a..4ee709b17f 100644 +index e7ddb237b1..9cb25bbf3a 100644 @@ -62 +63 @@ -@@ -7330,9 +7330,6 @@ ixgbe_get_module_eeprom(struct rte_eth_dev *dev, +@@ -7628,9 +7628,6 @@ ixgbe_get_module_eeprom(struct rte_eth_dev *dev, @@ -72,5 +73,5 @@ -diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c -index 4365c55b81..ddc1371aa9 100644 ---- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c -+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c -@@ -1193,7 +1193,7 @@ mlx5_get_module_info(struct rte_eth_dev *dev, +diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c +index efcc69ca44..7af7fb0f9f 100644 +--- a/drivers/net/mlx5/mlx5_ethdev.c ++++ b/drivers/net/mlx5/mlx5_ethdev.c +@@ -1883,7 +1883,7 @@ mlx5_get_module_info(struct rte_eth_dev *dev, @@ -85 +86 @@ -@@ -1227,7 +1227,7 @@ int mlx5_get_module_eeprom(struct rte_eth_dev *dev, +@@ -1917,7 +1917,7 @@ int mlx5_get_module_eeprom(struct rte_eth_dev *dev, @@ -95 +96 @@ -index 9e3f80937d..6f0cdc5854 100644 +index beb4f58148..1f8292589c 100644 @@ -98 +99 @@ -@@ -520,8 +520,7 @@ otx2_nix_get_module_eeprom(struct rte_eth_dev *eth_dev, +@@ -533,8 +533,7 @@ otx2_nix_get_module_eeprom(struct rte_eth_dev *eth_dev, @@ -109 +110 @@ -index 3059aa55b3..bb195abe70 100644 +index fb0912a4a8..14f9a7134c 100644 @@ -112 +113 @@ -@@ -5335,6 +5335,8 @@ rte_eth_dev_get_module_info(uint16_t port_id, +@@ -4922,6 +4922,8 @@ rte_eth_dev_get_module_info(uint16_t port_id, @@ -121 +122 @@ -@@ -5348,6 +5350,8 @@ rte_eth_dev_get_module_eeprom(uint16_t port_id, +@@ -4935,6 +4937,8 @@ rte_eth_dev_get_module_eeprom(uint16_t port_id, @@ -131 +132 @@ -index 6c7c72890f..f5bbc10b68 100644 +index 017459e595..8fd7f272bf 100644 @@ -134 +135 @@ -@@ -4471,6 +4471,7 @@ int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info); +@@ -3920,6 +3920,7 @@ int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info); @@ -142 +143 @@ -@@ -4493,6 +4494,7 @@ rte_eth_dev_get_module_info(uint16_t port_id, +@@ -3942,6 +3943,7 @@ rte_eth_dev_get_module_info(uint16_t port_id,