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 9A0BB45492 for ; Wed, 19 Jun 2024 11:58:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 95854427C9; Wed, 19 Jun 2024 11:58:53 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2134.outbound.protection.outlook.com [40.107.236.134]) by mails.dpdk.org (Postfix) with ESMTP id 2D50E4026C; Wed, 19 Jun 2024 11:58:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jv2Vn9W977uKleeH7vCf/OxaQKSWYGSKAbXry6Cx6aYy4xSQ3ysoziBFtkTWuIz0oDpvqcm8bIobQEEAs5vM9Y7ls/aeQaSLZWDtBjhMfBX74NbrmHJ8KTW3b7HcLuaa93H6p3ztzH6DDe/GcgvOyAWE6HLUO/NRjOS0X0EovQlog+o60F2QdSRPr0vpxK/9CpqG9w8JvqgJ3HQlo/+QE3Esb/UiIp6U22KXDzPARiF6e8CqFRMNfz1HUeF3HyYkLwjyl0dd7IyQlRLh1LQiWEWX4t00xICGLeINZ4eh9vwK++P71uGyhc8teo9WMJa1acvmfCo4Y3XifXpPHhV76Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=N4WVDIaK6hlZw0tzhAdHsu5YH2+HxL6NK76v9dC++gI=; b=n4s7Bj2kFRkc4HtWVLbMU4Alc6ii0t17XPMb1FX2ciHCHCbuAPAYHezG/aRU+1A9q8Flk1r/02Zi9fI3rMdmvU9mReDTuleqUhXG1I36fw4ekx9wqHxYIwKfrApGTjGUYMq9DhVrYMwRM5mkVeIoP36uCrQoNkTrdXSQciDb4XQ5An3eMHSgX5KMx4kzn1j+0nmyM8Ht126rhvPT95lt8wZy6A2V+v4BJkh9BTZg4PR9bh6t9NyXLpL9zFN941oIM4hS6olZ/rMSmc6Eg+ivqPvdAWA/zk9OogZXmJVbcY6X/ztoojiivonfEESx9BCEyOs4HkBYAWLXi2j+lCGnoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N4WVDIaK6hlZw0tzhAdHsu5YH2+HxL6NK76v9dC++gI=; b=HBlVzU0kobirRhjGTz4eZ5qAYnLzCf5O1OUNXV2S5qbuCKlj3nI34I8jiOHti9VnbDXVpL+on6Hj9dWa9mYc8qZp8l91JoxxODirtxPW1hAYf+mO6ZQWXGW1nn16wjVjrApTP6xHyLQJsUG9mrkJwO0ZaoCx4qQ/a603nCI9ojw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by CO3PR13MB5782.namprd13.prod.outlook.com (2603:10b6:303:171::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.20; Wed, 19 Jun 2024 09:58:49 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833%4]) with mapi id 15.20.7677.030; Wed, 19 Jun 2024 09:58:49 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Peng Zhang , chaoyong.he@corigine.com, stable@dpdk.org Subject: [PATCH 01/23] net/nfp: fix dereference of null pointer Date: Wed, 19 Jun 2024 17:58:08 +0800 Message-Id: <20240619095830.3479757-2-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240619095830.3479757-1-chaoyong.he@corigine.com> References: <20240619095830.3479757-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR13CA0057.namprd13.prod.outlook.com (2603:10b6:a03:2c2::32) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|CO3PR13MB5782:EE_ X-MS-Office365-Filtering-Correlation-Id: 98778f11-ab95-40df-15ab-08dc90466aeb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|366013|52116011|376011|1800799021|38350700011; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?V8I1QsAmNM3ApZY155r9xlG2+f3g1t1wzslSd7lfj7ZCJMEZFjQxb1a2Yk4l?= =?us-ascii?Q?DFHzU9rsR3ONw8lTezJikCoU52FHb98ETtKlkshtKBPp04aDIylqCe8f6URF?= =?us-ascii?Q?0vw5RuCYZANEFpUmAHesGuKJWuHZKXdjMTcL+VEvP+dVeyMeYd7CPNW1ekQD?= =?us-ascii?Q?0fJw6vLI9KYPm4r6KAX0qp0CAlPSrIJkTmkfMrp5tGxN7dRsjRbbWr/3dYne?= =?us-ascii?Q?s8Wdo7ABEVuZnavRZqQGiCsJoaeT5hTr2VKoZQTC2WmUjp7sMF0KJA4Byu7l?= =?us-ascii?Q?447v5tf5ziKzWY6K+Kau2mKbrxFsTSwudGF/jC/bCOaY7imyklpjVMQK0yED?= =?us-ascii?Q?BlWm97f8HVh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U?= =?us-ascii?Q?EcXQCO60nBBLxtbesxmuktBQDS8Wk3hT5NsCht/vBejKWGopxBTqHi5WX+t2?= =?us-ascii?Q?7P5t5SPcQBagbPYbNlMR/P/I9hSBps7xsjhOppTbjKsCKv8dfdvtQ/FioLKI?= =?us-ascii?Q?5I6nQts=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230037)(366013)(52116011)(376011)(1800799021)(38350700011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?lWgdJiJLdP8nuBX05x0IbZQlMD6+PmFg+0/9W+RqQF40qn8oToY8lJMF62Uu?= =?us-ascii?Q?GIAUNmT4D55/Y1ClFGxAVU41Pu+j9jgAEXdu43PIrxcUHQAJpfr4dhqqzxwE?= =?us-ascii?Q?rSwOoUf82S9AKz6jyZ9MFLMG7tv+Z4T7tA56C7ojU7iIyjff2f+E9KAtEh63?= =?us-ascii?Q?iDCNVWBoCq7mYkONvLzgu8afJ2cAmq8f/U+U9ZyPd2l1mq3EicFLaEFVaCxf?= =?us-ascii?Q?a5tcuzu+/EPAh7guxU2UhtR74cGa7FmPK1mnkVWwLL6VjP6hXBnslrSkC2BY?= =?us-ascii?Q?Ylun2et6DqbFrVJThgB2rApjADbr+pMfE7DS9JGmbUwsQrMZHX2s0n+KNPuN?= =?us-ascii?Q?YuVv2uWU9pQ4FhH6pktNQa0xF4lo4eZ611BxsmzbitF6qfi31ABRIOD4m9oI?= =?us-ascii?Q?QsltRItHbG32G/n4A47++Wyv06ogLdI/eCQNRz98g3I1IqbcuSXGUDdqgNbW?= =?us-ascii?Q?vJqXCqx8is55Id3PgoxdO2hiLXqq4WvQlwunj4fZKjUUrBboyIW/7sGutxvJ?= =?us-ascii?Q?yk9hvc/6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VUJUgT/v6O/iC?= =?us-ascii?Q?N4bCS8aejXr0ZdPV3Lyrzg24i61fWDPWeIdI/ML4JgLkhSLcrw71TKslwb1F?= =?us-ascii?Q?Ok8nD6eZ8Rpuw6aGfukGlfUJQGeBwdS1McjAvdWwFV0P061mWkZdR59u1TgM?= =?us-ascii?Q?UVDBmtsBEP1CbG35Fe+OHIKMF8eVk22JiKmiUN3ijdSBNw4bxu+icrEKFdzn?= =?us-ascii?Q?UQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 98778f11-ab95-40df-15ab-08dc90466aeb X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2024 09:58:49.8282 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jNnUUqFNMJsu1x4W26ArDFOCNggFnGp+6FqCYDA2S0aldWGm8cpeH1udYhrshYlVZv3SHEesu0xgRHQcK6q4zLxXps8A1zK659Xo040UAJ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO3PR13MB5782 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 From: Peng Zhang The original logic can call the uninitialized parameter 'process_private' to get 'struct nfp_net_hw_priv', so the null pointer will cause a segment fault problem. This commit will add the "struct nfp_repr_init" as the parameter, it includes "struct nfp_net_hw_priv", it can fix this bug. Fixes: 149850c5b8ec ("net/nfp: support xstats for flower firmware") Cc: chaoyong.he@corigine.com Cc: stable@dpdk.org Signed-off-by: Peng Zhang --- .../net/nfp/flower/nfp_flower_representor.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index e7550ce9ef..7f12a9dcaa 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -19,6 +19,11 @@ enum nfp_repr_type { NFP_REPR_TYPE_MAX, /*<< Number of representor types */ }; +struct nfp_repr_init { + struct nfp_flower_representor *flower_repr; + struct nfp_net_hw_priv *hw_priv; +}; + static int nfp_flower_repr_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) @@ -603,6 +608,7 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev, int ret; uint16_t index; unsigned int numa_node; + struct nfp_repr_init *repr_init; struct nfp_net_hw_priv *hw_priv; char ring_name[RTE_ETH_NAME_MAX_LEN]; struct nfp_app_fw_flower *app_fw_flower; @@ -610,12 +616,13 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev, struct nfp_flower_representor *init_repr_data; /* Cast the input representor data to the correct struct here */ - init_repr_data = init_params; + repr_init = init_params; + init_repr_data = repr_init->flower_repr; app_fw_flower = init_repr_data->app_fw_flower; /* Memory has been allocated in the eth_dev_create() function */ repr = eth_dev->data->dev_private; - hw_priv = eth_dev->process_private; + hw_priv = repr_init->hw_priv; /* * We need multiproduce rings as we can have multiple PF ports. @@ -785,6 +792,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower, int ret; const char *pci_name; struct rte_pci_device *pci_dev; + struct nfp_repr_init repr_init; struct nfp_eth_table *nfp_eth_table; struct nfp_eth_table_port *eth_port; struct nfp_flower_representor flower_repr = { @@ -793,6 +801,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower, }; nfp_eth_table = hw_priv->pf_dev->nfp_eth_table; + repr_init.hw_priv = hw_priv; /* Send a NFP_FLOWER_CMSG_TYPE_MAC_REPR cmsg to hardware */ ret = nfp_flower_cmsg_mac_repr(app_fw_flower, nfp_eth_table); @@ -840,9 +849,10 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower, * Create a eth_dev for this representor. * This will also allocate private memory for the device. */ + repr_init.flower_repr = &flower_repr; ret = rte_eth_dev_create(&pci_dev->device, flower_repr.name, sizeof(struct nfp_flower_representor), - NULL, NULL, nfp_flower_repr_init, &flower_repr); + NULL, NULL, nfp_flower_repr_init, &repr_init); if (ret != 0) { PMD_INIT_LOG(ERR, "Cloud not create eth_dev for repr"); break; @@ -868,10 +878,11 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower, snprintf(flower_repr.name, sizeof(flower_repr.name), "%s_repr_vf%d", pci_name, i); + repr_init.flower_repr = &flower_repr; /* This will also allocate private memory for the device */ ret = rte_eth_dev_create(&pci_dev->device, flower_repr.name, sizeof(struct nfp_flower_representor), - NULL, NULL, nfp_flower_repr_init, &flower_repr); + NULL, NULL, nfp_flower_repr_init, &repr_init); if (ret != 0) { PMD_INIT_LOG(ERR, "Cloud not create eth_dev for repr"); break; -- 2.39.1