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 98FE6A0C47; Wed, 3 Nov 2021 19:35:47 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 61F404111B; Wed, 3 Nov 2021 19:35:41 +0100 (CET) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2049.outbound.protection.outlook.com [40.107.95.49]) by mails.dpdk.org (Postfix) with ESMTP id 97ACB410FE; Wed, 3 Nov 2021 19:35:40 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b5N+rm8QKmfJJKaeGWDO5SARESQDSxkrYYlNkYeYBaq3KFV0qrRV6Jm7fN0BRLT5ZAY2Tf39xepksrHaHrdV3F9p65qFZIOTeRUmyyVB+hChJ9dPD2ORxOM8NItxMAniZ4XjLfgExeC2R8rsTq9MiH0SYsl0MhT89dfADSCqS9nKQ62Dlp4dp95pEfVC90B/vYeEipnPPUmT+gwvo2xqEKjRe2Yd2/zh3tIcm2VFj2JUKtrBi2mnafWDAqhJicvFlw180u1rIl5TQfgP2keIYuXxoQearT/M8VtSRng5jOY7wA4Y03u0/Gc5dbpFWsV55N9oPLUIXZjit4qTFg5i6g== 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=Wcnuc6mSmtCLD06eYV6WTHSDR9WL20GUxjwe3xCwGz0=; b=ZC6NhAJDosOJx8c8W9wd7TihQOgi8SV8+nTLw90RCPSIPmH2kXClxAxcelg096iuL7HwQmHfeBOtUTlaz+ayAJBJNuyo/iEgU+Jtf05ejDleqQRkv7xdqZkUQ11c9LQGVXj6HFHoAQsyjbgZDAqPQoZ5UOCF89RgQtay/RK1LVgTeUVxnNpsoHd+HYkf2u94JVicwn2DoKlkA+aRT2N8blJmvh7awM+X4OBXjrnVfkjZGvMLYj1Wz9GwPmb6JgH7Rnpw09X/tMfbgQPj4PuLmkfIiUsC2pVAVrFk1cULYlLwM1lKpsOpN5WGL17dsVs+pHRCygG9selnJtWBHubnsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine 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=Wcnuc6mSmtCLD06eYV6WTHSDR9WL20GUxjwe3xCwGz0=; b=pXvaNKWfHINExHZ1iqrwSZwUWZ5b8NyVIwWa38AOnLGZXSyk/wO1laeLpXBEmfXnnSehCmOGkpT3FjvpFo791srAA/eMQxsynzRqIN812qI3P+n7JAeSuUs5wfwD0p+QK8YaAAs4XuXR7pa1y4QK0zxq7/NDiuGlp4pSwFxGHzZYjPmpZzQiIkAMsHXjb5yi4kduGNR5ay1KFkaNYZih5iepzO9HhHv99NjhrP7Axn4UbQEHBdUd5WmRqUeI7jaxzZKHTvsuh7YGrIvPNl6B1tT32uGIekvbT9/8Q9wb0MU1qVkI5xEJEwCO186WqiI+79NrD1ngW50D81MXEIhG5Q== Received: from DM6PR03CA0081.namprd03.prod.outlook.com (2603:10b6:5:333::14) by BL1PR12MB5077.namprd12.prod.outlook.com (2603:10b6:208:310::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Wed, 3 Nov 2021 18:35:38 +0000 Received: from DM6NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:5:333:cafe::f3) by DM6PR03CA0081.outlook.office365.com (2603:10b6:5:333::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Wed, 3 Nov 2021 18:35:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; 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 DM6NAM11FT013.mail.protection.outlook.com (10.13.173.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4669.10 via Frontend Transport; Wed, 3 Nov 2021 18:35:38 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 3 Nov 2021 18:35:36 +0000 From: To: CC: Matan Azrad , Thomas Monjalon , Michael Baum , , "Viacheslav Ovsiienko" Date: Wed, 3 Nov 2021 20:35:08 +0200 Message-ID: <20211103183513.104503-2-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211103183513.104503-1-michaelba@nvidia.com> References: <20211103183513.104503-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 16b67ce5-a85b-41c4-5063-08d99ef8bb61 X-MS-TrafficTypeDiagnostic: BL1PR12MB5077: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SQK1UbtE2bMAtLb5BUwE4XuO46gE7y4dD7qdZz4lVuBNg10FzrNWDiBcJKuuyJCuOvd1QdcqqTMCcNpTFMb7rZ22eB80bz16LtsCSNgaE7bv3xGygXX0kKsqKTvGS9wZhmfSHcI3xpHUgDACDJA1+bCUEUUXe2gJfxst1PPGWQAAj2Q9bSUW2nv4Gyuj4DW+04BTwGDtiPpEd2Bpua44mCllRMHkwHckVPfzQ0xWVI/RHtv03i66Y85QdMjjGK4JZmGymIYyMhN71R8Fg1zVdZBFee9uQfsaLGp67Iqvblmo4F38l2B1uSIprQ9Rygq333T35ovW6i/fh+Z3uayyiOhTYxk5BClqD7jfZqZstugQEB6PAUmZNc3RthEOygXE3KNWr/uM3ZePE72V+Kr5WNUePR5liVKdg3py8fq5wvW42mCk9b7Vd3YfUveg8YhmQ87eebES2uppuIEVLBFAkAYlezylc3ZaXmNn1JpZjdHM2oDy3YqXxQf/sS7nU+RplUB159jJx7u1r/6GpSlsl1fm11zCUKeUpD/DdLYZ+uwJaSMKFUfsIhvBeutBYCvKp+UCIGSohtbukuODvFNocTblgg1TQarQzG0WeQa2RJBPcSbJJYkVTNswtJsmLVX48g6G2JKwJbD3R4RB9607JtiAvrXGzsdTmgP6Ki5e+L52e7Blb0ICHdW0mQ0ZYpaSDbURAXTl1I61u0N3qzA23A== 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)(46966006)(36840700001)(86362001)(336012)(7696005)(6666004)(508600001)(70206006)(1076003)(82310400003)(47076005)(2616005)(426003)(55016002)(4326008)(5660300002)(70586007)(6916009)(107886003)(26005)(316002)(16526019)(8676002)(186003)(36756003)(6286002)(356005)(2906002)(83380400001)(36860700001)(2876002)(54906003)(7636003)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2021 18:35:38.1021 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 16b67ce5-a85b-41c4-5063-08d99ef8bb61 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: DM6NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5077 Subject: [dpdk-dev] [PATCH 1/6] crypto/mlx5: fix invalid memory access in probing 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 Sender: "dev" From: Michael Baum The probe function creates DevX object named login and saves pointer to it in priv structure. The remove function releases first the priv structure and then releases the login object. However, the pointer to login object is field of priv structure, which is invalid. Release the login object and then release the priv structure. Fixes: debb27ea3442 ("crypto/mlx5: create login object using DevX") Cc: stable@dpdk.org Signed-off-by: Michael Baum Reviewed-by: Viacheslav Ovsiienko Acked-by: Matan Azrad --- drivers/crypto/mlx5/mlx5_crypto.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/mlx5/mlx5_crypto.c b/drivers/crypto/mlx5/mlx5_crypto.c index f430d8cde0..f9fd0d498e 100644 --- a/drivers/crypto/mlx5/mlx5_crypto.c +++ b/drivers/crypto/mlx5/mlx5_crypto.c @@ -878,12 +878,6 @@ mlx5_crypto_dev_probe(struct mlx5_common_device *cdev) DRV_LOG(ERR, "Failed to parse devargs."); return -rte_errno; } - login = mlx5_devx_cmd_create_crypto_login_obj(cdev->ctx, - &devarg_prms.login_attr); - if (login == NULL) { - DRV_LOG(ERR, "Failed to configure login."); - return -rte_errno; - } crypto_dev = rte_cryptodev_pmd_create(ibdev_name, cdev->dev, &init_params); if (crypto_dev == NULL) { @@ -899,12 +893,20 @@ mlx5_crypto_dev_probe(struct mlx5_common_device *cdev) crypto_dev->driver_id = mlx5_crypto_driver_id; priv = crypto_dev->data->dev_private; priv->cdev = cdev; - priv->login_obj = login; priv->crypto_dev = crypto_dev; if (mlx5_crypto_uar_prepare(priv) != 0) { rte_cryptodev_pmd_destroy(priv->crypto_dev); return -1; } + login = mlx5_devx_cmd_create_crypto_login_obj(cdev->ctx, + &devarg_prms.login_attr); + if (login == NULL) { + DRV_LOG(ERR, "Failed to configure login."); + mlx5_crypto_uar_release(priv); + rte_cryptodev_pmd_destroy(priv->crypto_dev); + return -rte_errno; + } + priv->login_obj = login; priv->keytag = rte_cpu_to_be_64(devarg_prms.keytag); priv->max_segs_num = devarg_prms.max_segs_num; priv->umr_wqe_size = sizeof(struct mlx5_wqe_umr_bsf_seg) + @@ -940,9 +942,9 @@ mlx5_crypto_dev_remove(struct mlx5_common_device *cdev) TAILQ_REMOVE(&mlx5_crypto_priv_list, priv, next); pthread_mutex_unlock(&priv_list_lock); if (priv) { + claim_zero(mlx5_devx_cmd_destroy(priv->login_obj)); mlx5_crypto_uar_release(priv); rte_cryptodev_pmd_destroy(priv->crypto_dev); - claim_zero(mlx5_devx_cmd_destroy(priv->login_obj)); } return 0; } -- 2.25.1