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 D9302A0543 for ; Tue, 21 Jun 2022 10:04:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D39CB40151; Tue, 21 Jun 2022 10:04:41 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2087.outbound.protection.outlook.com [40.107.223.87]) by mails.dpdk.org (Postfix) with ESMTP id 986F340151 for ; Tue, 21 Jun 2022 10:04:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MSCLGCqEwjDVc4ika8sEjrKaNfK28WcGjWa4E41JYij6kk+oXFAfH0EGXU49cuEKGbowX3bI27ygMR5JE5CMitEIGZIkZPQx3eMJl7TE7WYsLLuT9iMmgxA15N+b70wYXfvJDOLNoS/0HoY8wRQ8Wu/DTFYHVPCsQZNzNzP2MS/198zDYUxXGj0b8ds0vxarfXmdlhwUvq27baY5KT4H55FlnsO92X/2As6a+aOEvxc2MqeQfUsBL3oMFEiPI7oesYW5ri8ntPdkJy1nFASngmaMvo9lzODnFEaFNlGsyZtOTwXCaGan8ASVCXgySKg8mHX9CKUY4exx5yss9K9doQ== 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=4V4M4QJIrw2YQCddQv8ucoX2FMeNivt1BMJCiONozU8=; b=WY4D/xoEkN1UMd0zwT3dND39kqHRNvpsNyHo08PRMP+XQwLgxNXRpG03Mjny0o+J5SsTxgLsC6qzAfT3Us8J6OE4ED/v7TzkRXcZeIqOtnK1jzUSUJYjHCJjR7T/LbJuATcxbqPJ0jcBcW/lLCNP/Fkm0OMVJc/6m4+acgY5hpdl+7+kwpa3dSWJILDsn1JGYZmo9hIko08l0Q2X+tlbzpjvmol2p3zUWwCkYNbqOwouH93kB2i0ZD1mHVDQdJ2nohjCdFIplKE9NFgH8pCTQjkbiVb97pBQ9ZoHAkKjhD2OZrFl/HX5faKHhxAN6akeSiu/bVLy54EsQmzBbM/6Fw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) 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=4V4M4QJIrw2YQCddQv8ucoX2FMeNivt1BMJCiONozU8=; b=D3HEwoy6kuuJj5skG47H+s8QxR2s0/vDCnLofAXW6v+/A51qugpSyEJjO5Eu07YM5mASR/Yw3+A9SDO0L0wH4/ipuiKV6M/QIE5vKPQ1tDQMaet804bv8tgGzlmmsAE/D1CZHBZ11jQ+8dNkFg6m0YRybyGWsB8qIM466HmTq9Ty8e5sZXlGW8uvGqza3zfcDSyVo5mU6bwL10HF6R/jXrlN30Lzc6Amz7cLO7nzxpBZlr/Nrj4OpbNUM0mFo0zkQ/UUgv6uzEjZU8zlXjXF3C8phXV0MFA06rV1076BlbGHLRa174Tb7mhgU8GQ9iRSdY/d8Wh+dP6XYEGLy9bKrg== Received: from DS7PR06CA0037.namprd06.prod.outlook.com (2603:10b6:8:54::12) by LV2PR12MB5967.namprd12.prod.outlook.com (2603:10b6:408:170::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.18; Tue, 21 Jun 2022 08:04:37 +0000 Received: from DM6NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:8:54:cafe::5e) by DS7PR06CA0037.outlook.office365.com (2603:10b6:8:54::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.14 via Frontend Transport; Tue, 21 Jun 2022 08:04:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.236) by DM6NAM11FT022.mail.protection.outlook.com (10.13.172.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5353.14 via Frontend Transport; Tue, 21 Jun 2022 08:04:37 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Tue, 21 Jun 2022 08:04:36 +0000 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 21 Jun 2022 01:04:34 -0700 From: Xueming Li To: Gagandeep Singh CC: Akhil Goyal , dpdk stable Subject: patch 'crypto/dpaa2_sec: fix fle buffer leak' has been queued to stable release 20.11.6 Date: Tue, 21 Jun 2022 11:01:22 +0300 Message-ID: <20220621080301.2315720-17-xuemingl@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220621080301.2315720-1-xuemingl@nvidia.com> References: <20220621080301.2315720-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2c7fc0a5-2d91-4268-f5e0-08da535caf90 X-MS-TrafficTypeDiagnostic: LV2PR12MB5967: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: Xiyd7xrXH9/sMAKD+mBasGHkNhiGXBsRh94WsUTetoWhG6+C9NT/1HvqlGtmK2U0MhZS/ra18tayZzXbqchjDtjO+fTMACabgKffyWHaGVRCvQppj2/AJHUI4gdBUkAjnppzuyVQkyPD+GHd4SMb7NL3+M9wpiQbMiZVsHv/Ph+TCcf/p1xmfnXdqco/8amHvcq5yr++Swz+jzUaFaB1vSVF+sQwpaUqU+Wks+XtAn7m5ozpTMPt4CqUNj9YKhcRqhr1yUO4SPNajPouYEG7PzceTXT2DYn9xz2XGYvamDab62mbmcu/FhCepGrgX+ojVfgrKbP+2YBoCOJGPJ39rX4BTiBsStBt/TLH4NdOAqDKsRPQ4uxkekBnPM8dXAvlCmu0cNo9tid+s5MmvvNZG3+UcKTICJGanVDNRsLhqxcC5Xm5HeDrOGBnSxWEki6n4rk9TxrAdbTCQV0/hcmjhPvndmte8xeqCzbqHhF+b+YlH/xOQQOk6qcj2Y1FJuf6SEpoz5UfU/NtCKFoBr1plDiDurgupxGcNQOzKEbUMo++P6qykjhQewt7yCcbD/8zraWUh6zP1/U+1+xM4SwNpg/10tFv2AIzTO4g8oCuDFHsXR5gxgD1V2a11Gy4E8XeeTqdDz/zSnE3OfWO1NRRgX1xjZmPb3Va4V6nXS8jkfQnd7Jd+G7fMmivych2zvy78wK3aMbNM5h+GmU1tFQg/HR3xwJKQ+FCmlsrgkjH2e3BmkkXAYPpW5nnleJoGCJV6hHTWQh5p2FPI7aK+32o9WcuAkefCCjYJDPcgFi2t4EO2r1EEmOrvxy6QeaURSkyOZVWFPwwCJBTbkqe3Di8tYjb7Ne+wRtabGzrATH69rk= X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(346002)(136003)(376002)(396003)(39860400002)(46966006)(36840700001)(40470700004)(81166007)(82740400003)(70206006)(4326008)(86362001)(55016003)(356005)(82310400005)(16526019)(40460700003)(8676002)(36860700001)(336012)(966005)(426003)(316002)(54906003)(53546011)(6286002)(6916009)(186003)(8936002)(40480700001)(26005)(47076005)(5660300002)(2906002)(83380400001)(7696005)(1076003)(2616005)(6666004)(478600001)(41300700001)(70586007)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 08:04:37.2862 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2c7fc0a5-2d91-4268-f5e0-08da535caf90 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.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT022.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5967 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 Hi, FYI, your patch has been queued to stable release 20.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/23/22. 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/2a680bbbc72df42818ae33007df4e82aaa2fee5f Thanks. Xueming Li --- >From 2a680bbbc72df42818ae33007df4e82aaa2fee5f Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Thu, 28 Apr 2022 17:17:20 +0530 Subject: [PATCH] crypto/dpaa2_sec: fix fle buffer leak Cc: Xueming Li [ upstream commit 6a2b01a4106402be0aa50e3e3b1e5098e3a9b646 ] Driver allocates a fle buffer for each packet before enqueue and free the buffer on dequeue. But in case if there are enqueue failures, then code should free the fle buffers. Fixes: 4562de326d30 ("crypto/dpaa2_sec: support ordered queue") Fixes: 3ffce51a1f04 ("crypto/dpaa2_sec: add enqueue retry timeout") Signed-off-by: Gagandeep Singh Acked-by: Akhil Goyal --- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 29 ++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index 7e728d1cf7..c9e378d467 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2016-2020 NXP + * Copyright 2016-2022 NXP * */ @@ -59,6 +59,27 @@ static uint8_t cryptodev_driver_id; +static inline void +free_fle(const struct qbman_fd *fd) +{ + struct qbman_fle *fle; + struct rte_crypto_op *op; + struct ctxt_priv *priv; + +#ifdef RTE_LIB_SECURITY + if (DPAA2_FD_GET_FORMAT(fd) == qbman_fd_single) + return; +#endif + fle = (struct qbman_fle *)DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd)); + op = (struct rte_crypto_op *)DPAA2_GET_FLE_ADDR((fle - 1)); + /* free the fle memory */ + if (likely(rte_pktmbuf_is_contiguous(op->sym->m_src))) { + priv = (struct ctxt_priv *)(size_t)DPAA2_GET_FLE_CTXT(fle - 1); + rte_mempool_put(priv->fle_pool, (void *)(fle-1)); + } else + rte_free((void *)(fle-1)); +} + #ifdef RTE_LIB_SECURITY static inline int build_proto_compound_sg_fd(dpaa2_sec_session *sess, @@ -1508,6 +1529,12 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops, if (retry_count > DPAA2_MAX_TX_RETRY_COUNT) { num_tx += loop; nb_ops -= loop; + DPAA2_SEC_DP_DEBUG("Enqueue fail\n"); + /* freeing the fle buffers */ + while (loop < frames_to_send) { + free_fle(&fd_arr[loop]); + loop++; + } goto skip_tx; } } else { -- 2.35.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-06-21 15:37:50.022687811 +0800 +++ 0016-crypto-dpaa2_sec-fix-fle-buffer-leak.patch 2022-06-21 15:37:48.984451063 +0800 @@ -1 +1 @@ -From 6a2b01a4106402be0aa50e3e3b1e5098e3a9b646 Mon Sep 17 00:00:00 2001 +From 2a680bbbc72df42818ae33007df4e82aaa2fee5f Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 6a2b01a4106402be0aa50e3e3b1e5098e3a9b646 ] @@ -12 +14,0 @@ -Cc: stable@dpdk.org @@ -17,2 +19,2 @@ - drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 35 ++++++++++++++++++++- - 1 file changed, 34 insertions(+), 1 deletion(-) + drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 29 ++++++++++++++++++++- + 1 file changed, 28 insertions(+), 1 deletion(-) @@ -21 +23 @@ -index e62d04852b..03fef5e500 100644 +index 7e728d1cf7..c9e378d467 100644 @@ -28 +30 @@ -- * Copyright 2016-2021 NXP +- * Copyright 2016-2020 NXP @@ -33,3 +35,3 @@ -@@ -64,6 +64,27 @@ enum dpaa2_sec_dump_levels { - uint8_t cryptodev_driver_id; - uint8_t dpaa2_sec_dp_dump = DPAA2_SEC_DP_ERR_DUMP; +@@ -59,6 +59,27 @@ + + static uint8_t cryptodev_driver_id; @@ -61,14 +63 @@ -@@ -1513,6 +1534,12 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops, - if (retry_count > DPAA2_MAX_TX_RETRY_COUNT) { - num_tx += loop; - nb_ops -= loop; -+ DPAA2_SEC_DP_DEBUG("Enqueue fail\n"); -+ /* freeing the fle buffers */ -+ while (loop < frames_to_send) { -+ free_fle(&fd_arr[loop]); -+ loop++; -+ } - goto skip_tx; - } - } else { -@@ -1854,6 +1881,12 @@ dpaa2_sec_enqueue_burst_ordered(void *qp, struct rte_crypto_op **ops, +@@ -1508,6 +1529,12 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,