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 46985A00BE; Sun, 10 Apr 2022 11:25:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6549C427EE; Sun, 10 Apr 2022 11:25:44 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2084.outbound.protection.outlook.com [40.107.223.84]) by mails.dpdk.org (Postfix) with ESMTP id 35CA1415D7; Sun, 10 Apr 2022 11:25:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I1t7Rb16n925JOUBcQyxcoa5XV2lzCwoPmom+j7qnlvmZtCa3Fp7bDXlbQzXvhaSNv8vnpN/0Q5L5E9mYprXpsWBwlQq3B2RBcAmI0RGs/ycEkL10SRyjFUkstHbGoZubOjQPEZi/RaDJYK6Z/Q1uiKnqnRHPf7hg0EIMt4D4y5yhsy68zHX/OccpPkiJj+3KzBBmNMr+WNcHkkZOe2vhnUJw/hV/5kAQlAAQnt+llw7XYRxB2PWp0I0tNbKLE+AWK9d/U0M+SkkynLt1CBJwj0QfEE1XZwXRy0oS3HEj4MkTozsMh9J6dPVbSFmbL9+uDrzkx5Zy2UHxkGEV4meIg== 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=nIX6Qjkx46waGKtGMY0vjFlfjoviJCpBs1ZI616wJIE=; b=JbPwzWSCkAKRkJlcp1vP/SLlTpb0XT13GHBwYcm3tW23Hb0uY/O+Nk5MN+kIcRb3XxOJ822yRBPX+qO70csRFNBKJMhLj8AiFMx3q7Lecy9rfwOGlmuMdP/hGDw95KrmauH1Krgb98Mz2Buuffu8+gr/cFXGzFH3j8wYaJWw8UTC3BaJwfk4w3O7EzpKGCIrwIcriQrtTqXq2pj5JAKXVBuLS6IiDsGE7Xem8/rgJktl9SuSK8oNMlBVsIEPkghIVcseh1ccNMKO9iUcHrJDUtYoIFXwQZzXydEGrzkecFR+WgDmEe6W9meVW7pCLMR5mPVuLScoRpVGR63vtYo8JQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=nIX6Qjkx46waGKtGMY0vjFlfjoviJCpBs1ZI616wJIE=; b=uPEX8LVT/s2VVvdiF2jjgAxPb07YmZWjRT7S62o5sggAiBgO+fx9NWEv61NCZ37263DunuDdU/+S3GyFFg63CdZ+7v7yqyQi/fT70tKPxoRglJZUTdkaSYlYTfYxV8xBkL22kJqjzCptJTAE3OoZnEkWLUwkvAk2U2x8JtJO8ZirBbZ7myfCjZOTn58dVoFq2GnH8egMMaHbgC+TFHi5hMOiVo290Zmv7psyDg3jw2XVn25uFhENJNyKZL1wAXZ9n4eaMW//AdLAAe3w/qEG0Q8RN1XmJqJ9fH+5fhlBG0HHoz2uzqhhvM3QmDmCx5AJvmvYKBYJ6lTi+fCkFdOmHQ== Received: from DS7PR03CA0269.namprd03.prod.outlook.com (2603:10b6:5:3b3::34) by SA0PR12MB4509.namprd12.prod.outlook.com (2603:10b6:806:9e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.28; Sun, 10 Apr 2022 09:25:41 +0000 Received: from DM6NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b3:cafe::7c) by DS7PR03CA0269.outlook.office365.com (2603:10b6:5:3b3::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29 via Frontend Transport; Sun, 10 Apr 2022 09:25:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT029.mail.protection.outlook.com (10.13.173.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5144.20 via Frontend Transport; Sun, 10 Apr 2022 09:25:40 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Sun, 10 Apr 2022 09:25:40 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Sun, 10 Apr 2022 02:25:39 -0700 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22 via Frontend Transport; Sun, 10 Apr 2022 02:25:37 -0700 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko , Subject: [PATCH 2/3] net/mlx5: fix reading invalid index in RxQ array Date: Sun, 10 Apr 2022 12:25:27 +0300 Message-ID: <20220410092528.1001685-3-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220410092528.1001685-1-michaelba@nvidia.com> References: <20220410092528.1001685-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4d1980de-50ec-41a1-1a98-08da1ad4149a X-MS-TrafficTypeDiagnostic: SA0PR12MB4509:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tAlE3xZPURRBSZ/9c+3kwcYfbMCoVO1GSferegAZ1vT38n1efbXe+w3UrhAhgsm0rtROc+Om5Q0NKzQqm1GPaR1eETJ8U/VKZ3Z6qkUrreiF9FDMJHrHmuyF3NmYhTO2RwZCM+kGrGxLohYRnknPDHGwXRnB016+XaGIWtoorqSfNu6UbP+aKUP/6BZXRJuIfjWSQAMdTUxsScxtnzzeC4M0eYs72AEmH3dy+jcqStk9gW75KfmJ8f2A19usvp97oPHX6qHcATB6VuCZKQk8lmoyu6qXeaEA8yApt+BObr7iHqKSsHv2DEvd8x0SzIcMn47gn4H5Yjn1FQXermSZKU59000wpc4vJxmjKanSPFdA3mnfU1IOh4loYNFfyS6CGGoKuDWck87O1ly/j5Cx+Ljn5pe9TKb1UrohLj4Fa1TaWeoAiFRRLwOIsYBhqGxTDVXytWxn0ib38FBzGUa5kQcR6cw5CSpj59SUiLD+6bNP7PxrralwN2YVB4JJvO/iqHUzLKZNriz0dkPiRncq2LGunpGUsV1wjnFApP7vjxt60i1LfVRC1mRG+Tx9jEJEoR4Ro2hnfv89WoCGks7JWr3uIxHZVl5uSHchaTSAAxJ3FVNgMdmWohSpMNGl8nb6gH6u9AkjZ3zuAVwKNTRUWGVyHDMBijK7/NvvsEar6JH6mk361QIHTHg3quzQJ+Z03lem8clsoIn6YfI8D1DfP/OsPREsKGiR/AXxwYfFxjaFLtIpNnrrGD3XqxDXETGo/TXxH02ex/bJFtgXZBcdYw== X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(186003)(336012)(47076005)(1076003)(83380400001)(81166007)(508600001)(426003)(26005)(6916009)(450100002)(4326008)(316002)(36756003)(8676002)(54906003)(70206006)(82310400005)(70586007)(6286002)(2906002)(2616005)(8936002)(5660300002)(356005)(55016003)(36860700001)(40460700003)(7696005)(4744005)(86362001)(6666004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2022 09:25:40.6129 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d1980de-50ec-41a1-1a98-08da1ad4149a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4509 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The mlx5_rxq_get() function gets RxQ index and return RxQ priv accordingly. When it gets an invalid index, it accesses out of array bounds which might cause undefined behavior. This patch adds a check for invalid indexes before accessing to array. Fixes: 0cedf34da78f ("net/mlx5: move Rx queue reference count") Cc: stable@dpdk.org Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_rxq.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index f16795bac3..d41834f46f 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -2042,6 +2042,8 @@ mlx5_rxq_get(struct rte_eth_dev *dev, uint16_t idx) { struct mlx5_priv *priv = dev->data->dev_private; + if (idx >= priv->rxqs_n) + return NULL; MLX5_ASSERT(priv->rxq_privs != NULL); return (*priv->rxq_privs)[idx]; } -- 2.25.1