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 6B152A0A0E for ; Mon, 10 May 2021 18:18:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6469840140; Mon, 10 May 2021 18:18:23 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2073.outbound.protection.outlook.com [40.107.93.73]) by mails.dpdk.org (Postfix) with ESMTP id 98E4140140 for ; Mon, 10 May 2021 18:18:21 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TwhgNADhvbm/M6m74kySiAzE1kfNDA6fHpS6UxGBrlBD0ko/y/S8LEFXnfFpNKgwIzYaUaEVQH03S3nIc4GFqB8y/YUGQUd7nDAFW4xPsWSyCY5bmxlnyDiq+tkcBy8qbX+pcud4MAmfntRg8dz2hOWORNKK9RJB8dyMOHnsaQNoKaUiJtofbUAvXSvu69Wjm+BUCYRNihVItyO3rtOQq9iBnHKo1D9O8LocV1EqY2VzbwpOsCTg7nm/PdNZcxroM/DRn26o77kQbNFmDnA39X3MMqRFiXy6EatoBs4roi2wxE5DU5lSO2eNFAqFRJ22TybKEyYVo/egTIBXoBAmZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=37qZwLbEhLzZ6soPR+uqfoLmmwnuvA8G5fhkf6E2NF0=; b=EYkuzD9Mex777vTmJDfPFG4SK+ORiIn+jjTy6GCeM8OczbstHdvBjZwzDAOgdwDm6hFCcSH3CLlmDmWeLUGLTl/t2zvGzyBdL4c1H8Vbj+x3f88VU593itYYZ74UsdfyyNz+JsUEujanghGld52vci8OjC2v6dZbnZxD0mCwf4cLoJ3dWqbfkHbyubdArKW2og0busvL+8udOlACn+0YCWk0Xs8EP6o3GjEyAlnZRuBL/yR0CU4iLDZ0r3DXpcjY25ogp2wpQ/KVht9+WcfuUfkC3WNYJPz7DyZogLQ1kze+WjPM6eIp2fWrMMP2YWpFPLkxELd3nLjN5b3pkP2NUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=37qZwLbEhLzZ6soPR+uqfoLmmwnuvA8G5fhkf6E2NF0=; b=WPMP2A2/HDF3ooOzKN4Btv6IBLTNTssL7qY7Rd3pMmLhov8Kd3DOmS7rM0PoVTnkRx1ILtbmfhGZ8P6y8iph4xhBeodT88f661gL+EI97eav+bEqtWqY08/FPixjut5pQ+bNlk5WqGflAkqTbRB5OI9OmyHFEtucVu7jXYfnN99symLIau2G6vIlKyx29yvAEC2/mTLlVH3rHXKMgK+XbOqPLE/aRU1qFZy+0WcRW4x1wTgatPzh7m7LqRs+wUFQLtJ71MOFxIHfeveRwjPBy7mE2ITscXzkShxaD500p2la7NAm8e8u43Lr2PAVQ7l/t+uiRkG7+mJzMhCyhv01NQ== Received: from DM3PR12CA0043.namprd12.prod.outlook.com (2603:10b6:0:56::11) by MW3PR12MB4345.namprd12.prod.outlook.com (2603:10b6:303:59::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Mon, 10 May 2021 16:18:19 +0000 Received: from DM6NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:0:56:cafe::e0) by DM3PR12CA0043.outlook.office365.com (2603:10b6:0:56::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Mon, 10 May 2021 16:18:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT027.mail.protection.outlook.com (10.13.172.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4108.25 via Frontend Transport; Mon, 10 May 2021 16:18:19 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 10 May 2021 16:18:16 +0000 From: Xueming Li To: Chengchang Tang CC: Luca Boccassi , Min Hu , Ferruh Yigit , dpdk stable Date: Tue, 11 May 2021 00:01:40 +0800 Message-ID: <20210510160258.30982-151-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210510160258.30982-1-xuemingl@nvidia.com> References: <20210510160258.30982-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c814ddf9-4c6c-45cb-8950-08d913cf39ad X-MS-TrafficTypeDiagnostic: MW3PR12MB4345: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B+qtHQZhMLqiaQZSNHQR8O1Uvxa45ObW4TIo60OIj7l4nVgHVZ7QmyCK/lP4Uxjd6lN1rhgp/osY4O+Z7oJ7lTTWZJRjqg9siVaupBdhubj0M4ffm4E09viE3Unqz0jb4EnRt4iZt7iNJh1HslhnfO9O0g1y6rqVC+E49ycOg+DBeLhIVudwZ3KEiOJrTH7kDfv0hdJbIFkWrNTo3RY44+QxEWvOZ7hfybr1dt9wZzlel444YsnWz8ykdi82wK+V+WXHT2c3rvnYml+j82uo0AZJrGlbgjW8HDMleAv8+dSxaa9izl9uq+cx/7qdPataHT7bmk/YdTgQcTpBmDLj29YM/MKy7nVNbe1ZDMT/z9gJ7+a97+8fuyZy3WkWLN3N8A93HyjCv0di3BbLdq3sibi1/da0hGWzIiOxjZbCcRiq1wLIyP8w5dRtPl0HhkG3SCsvxJkupr2+2ddi9hJ96XPb2TwooJbN1FjuyJ+LuE0TvOKJQ7pbZ1Ck++xnogwOgHbuyLMOfTsYW1+u8UQ5jFRSrBkqpVap3wHvSm4OgtZjtreZYoHm2/NcI4w7+eC7/XenhRE0VW944zck0Wl0GV9JJgd53V7/b5oq09859UyF8kBLvtJfq8Db5v3MxpmY8sHiCnWzMzcs/ql/f+9kef3dq++1YG1oRSQdXaQrnU0IBEhUl+08OjkA6P7c3Xg5c5SNkX+h2hQ0URUxe6UVuFdWhDNH0hojN3PJK0MQ3UgCKWTmQ/eqpvpwawRgYQZnTlEPXsisUocR4vZO0vldCg== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(346002)(376002)(136003)(39860400002)(396003)(46966006)(36840700001)(6286002)(82740400003)(7636003)(356005)(2616005)(426003)(36860700001)(336012)(186003)(6916009)(1076003)(47076005)(7696005)(4326008)(6666004)(16526019)(26005)(966005)(70206006)(5660300002)(2906002)(54906003)(83380400001)(36756003)(8676002)(55016002)(36906005)(478600001)(316002)(70586007)(53546011)(8936002)(82310400003)(86362001)(15650500001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2021 16:18:19.4938 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c814ddf9-4c6c-45cb-8950-08d913cf39ad X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4345 Subject: [dpdk-stable] patch 'ethdev: validate input in module EEPROM dump' has been queued to stable release 20.11.2 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 20.11.2 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/12/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/steevenlee/dpdk This queued commit can be viewed at: https://github.com/steevenlee/dpdk/commit/2e6638d89797271f386dacc49d50349b81fc96cd Thanks. Xueming Li --- >From 2e6638d89797271f386dacc49d50349b81fc96cd 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 Cc: Luca Boccassi [ 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/linux/mlx5_ethdev_os.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 7857be10cb..f3c76bac9b 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -5135,9 +5135,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 572bd96471..104f121436 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -11765,9 +11765,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 6195c7f025..d1d7b312b1 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -7340,9 +7340,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/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c index e36a78091c..f641cb936e 100644 --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c @@ -1169,7 +1169,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; @@ -1203,7 +1203,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 963cc285ed..919754130c 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 ecd46ac01f..8e34c874ac 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -5307,6 +5307,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); @@ -5320,6 +5322,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 f5f8919186..760214efb8 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -4414,6 +4414,7 @@ int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info); * @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. @@ -4438,6 +4439,7 @@ rte_eth_dev_get_module_info(uint16_t port_id, * - (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. */ -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-05-10 23:59:30.506929700 +0800 +++ 0152-ethdev-validate-input-in-module-EEPROM-dump.patch 2021-05-10 23:59:26.590000000 +0800 @@ -1 +1 @@ -From e2bd08d569d9821131d8e245446d24eaed145f21 Mon Sep 17 00:00:00 2001 +From 2e6638d89797271f386dacc49d50349b81fc96cd Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Luca Boccassi + +[ upstream commit e2bd08d569d9821131d8e245446d24eaed145f21 ] @@ -15 +17,0 @@ -Cc: stable@dpdk.org @@ -31 +33 @@ -index 25218da240..7d6d04abcb 100644 +index 7857be10cb..f3c76bac9b 100644 @@ -34 +36 @@ -@@ -5118,9 +5118,6 @@ eth_igb_get_module_eeprom(struct rte_eth_dev *dev, +@@ -5135,9 +5135,6 @@ eth_igb_get_module_eeprom(struct rte_eth_dev *dev, @@ -45 +47 @@ -index 2076717324..c03e4a0a4b 100644 +index 572bd96471..104f121436 100644 @@ -48 +50 @@ -@@ -11659,9 +11659,6 @@ static int i40e_get_module_eeprom(struct rte_eth_dev *dev, +@@ -11765,9 +11765,6 @@ static int i40e_get_module_eeprom(struct rte_eth_dev *dev, @@ -59 +61 @@ -index 2d308be48a..4ee709b17f 100644 +index 6195c7f025..d1d7b312b1 100644 @@ -62 +64 @@ -@@ -7330,9 +7330,6 @@ ixgbe_get_module_eeprom(struct rte_eth_dev *dev, +@@ -7340,9 +7340,6 @@ ixgbe_get_module_eeprom(struct rte_eth_dev *dev, @@ -73 +75 @@ -index 4365c55b81..ddc1371aa9 100644 +index e36a78091c..f641cb936e 100644 @@ -76 +78 @@ -@@ -1193,7 +1193,7 @@ mlx5_get_module_info(struct rte_eth_dev *dev, +@@ -1169,7 +1169,7 @@ mlx5_get_module_info(struct rte_eth_dev *dev, @@ -85 +87 @@ -@@ -1227,7 +1227,7 @@ int mlx5_get_module_eeprom(struct rte_eth_dev *dev, +@@ -1203,7 +1203,7 @@ int mlx5_get_module_eeprom(struct rte_eth_dev *dev, @@ -95 +97 @@ -index 9e3f80937d..6f0cdc5854 100644 +index 963cc285ed..919754130c 100644 @@ -98 +100 @@ -@@ -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 +111 @@ -index 3059aa55b3..bb195abe70 100644 +index ecd46ac01f..8e34c874ac 100644 @@ -112 +114 @@ -@@ -5335,6 +5335,8 @@ rte_eth_dev_get_module_info(uint16_t port_id, +@@ -5307,6 +5307,8 @@ rte_eth_dev_get_module_info(uint16_t port_id, @@ -121 +123 @@ -@@ -5348,6 +5350,8 @@ rte_eth_dev_get_module_eeprom(uint16_t port_id, +@@ -5320,6 +5322,8 @@ rte_eth_dev_get_module_eeprom(uint16_t port_id, @@ -131 +133 @@ -index 6c7c72890f..f5bbc10b68 100644 +index f5f8919186..760214efb8 100644 @@ -134 +136,2 @@ -@@ -4471,6 +4471,7 @@ int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info); +@@ -4414,6 +4414,7 @@ int rte_eth_dev_set_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info); + * @return @@ -137 +139,0 @@ - * - (-ENODEV) if *port_id* invalid. @@ -138,0 +141 @@ + * - (-ENODEV) if *port_id* invalid. @@ -141,3 +144 @@ - */ -@@ -4493,6 +4494,7 @@ rte_eth_dev_get_module_info(uint16_t port_id, - * @return +@@ -4438,6 +4439,7 @@ rte_eth_dev_get_module_info(uint16_t port_id, @@ -146 +146,0 @@ -+ * - (-EINVAL) if bad parameter. @@ -147,0 +148 @@ ++ * - (-EINVAL) if bad parameter. @@ -149,0 +151 @@ + */