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 CFD61A034C; Thu, 28 Apr 2022 13:48:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 986694281F; Thu, 28 Apr 2022 13:48:04 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20068.outbound.protection.outlook.com [40.107.2.68]) by mails.dpdk.org (Postfix) with ESMTP id 0C92C4281C; Thu, 28 Apr 2022 13:48:01 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GJRe3jPM2X1mO5bfeCV/t5/M96WHFpGeY7FJwkmUNbCM4IGKvZIcb+Dg1a0aIq7zn7Il6p3KimU6BfJ70gpDyV4ncrpfrDadtk0xWe8BVfG+PHyFnQ3q6KHx/Kkq5x0jjYS7/Fy9ubCt7r2y8paafYKyRiS2OWPo8IoEdcOnBh74gxpJLJJ19aL1Z7ajDvfRSk0Dpx4X7dqfyrTfOtBCThOo4HgdOBzBt+Vxdh4V/PqREilXc3MdtSI/UzWp4Gic9AnprnrS4fKwNQnBxU0trzBoUru+Hba2FRfEoSjE31BH7/kKMW9oa3RyhfqlmSQzJHH6jOU8xH9Uh5Xq+fgqvQ== 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=NGJVqoQlRBOBdwXVBdSqnANybdSEqEx2wn512knqfyk=; b=T4MOQ3d0ssYmoV2PZE087yj4Eky1q9QEWogyvGfkS2fjVUR5IxtPi6XeOG6gy6xICgzXwIfBuHz1CE2BqFoS42IgPTfPUvRkGvVJ8NIcAJnn2k1RLqkGPLFApdF5WIadohJ7jvq3mQCP/A6I/SunZvW14U9DDpuNhYIImEjGcOuglNRNN/4r6TDKN54awwmwdPz8JxH0bMScGgQ/6jP4ve+C/CutMuckywYR+EaMhX+B0kN/JFWzDm2QMpdccyP4IIt6axA8PFYCkBOWHM6Awod/ifWLZ2pGYMe+MlLPM0IJpJ1id/mJ8BuZShHjHxwH/NkYuHQbDs9uWpp+5Zg9aQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NGJVqoQlRBOBdwXVBdSqnANybdSEqEx2wn512knqfyk=; b=NFlyWyB8wV16q2h6kv6g1eDCpSBOVBNW995be88QEfAzNyR/CkbxBQiZmBEUrhLGG5bGEY/IP75XogTd8GYljFJnCgyuaRos3srr3SJOVLexokC5WnOmRgkvS+ZQZ82vH5ulQlfv2nFI5YjUzoCpqQrPqSgNH2lKV5aSKiIlXKg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8198.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::14) by VI1PR04MB4622.eurprd04.prod.outlook.com (2603:10a6:803:76::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.14; Thu, 28 Apr 2022 11:47:59 +0000 Received: from AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::8cf1:93b:c340:3be2]) by AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::8cf1:93b:c340:3be2%9]) with mapi id 15.20.5206.014; Thu, 28 Apr 2022 11:47:59 +0000 From: Gagandeep Singh To: gakhil@marvell.com, dev@dpdk.org Cc: Gagandeep Singh , stable@dpdk.org Subject: [PATCH v2 01/14] crypto/dpaa2_sec: fix fle buffer leak Date: Thu, 28 Apr 2022 17:17:20 +0530 Message-Id: <20220428114733.1419957-2-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220428114733.1419957-1-g.singh@nxp.com> References: <20220422035100.3180870-1-g.singh@nxp.com> <20220428114733.1419957-1-g.singh@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR02CA0002.apcprd02.prod.outlook.com (2603:1096:4:194::22) To AS8PR04MB8198.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b5b25896-788c-4e0a-ee20-08da290cf167 X-MS-TrafficTypeDiagnostic: VI1PR04MB4622: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: IA/CaybVql++/rcuL9CdfKlhdt4OrtPq3MJxO92SQCT8WtYDCzxL3ZtnsBUrUD1oriBSzE5DxhYnzbPIJiWL4h04Pwo12iuh1j+5UObzrvnttKj1pUJpZbvc6PtYq8JNPV++B3/UE+TB4gJaDy50b8mfFbQxiidN+sHjSD3PxO4iWHxOjUjmjnfuIGQfxNbtyFhRn1jsp57o4xk4YyJ/1df4xwnnACgQIqbHCE2JZjlm/2HZCaaGYR3CI8XzSkeL52rlxmJJJf61fgkiVIuOXQpGDHtPsXC2k44SQ4x3br4pc1C1S5SYUGJcHJN6UzOeUwEnthYfA1tL/rdtZ+5QGd/5JaNywOQRW0sYTWqh9n4LZyzXqLmYFHCrNuyzkOnugdcha/Q7711GfiV0cKhFWl1jZHDM59s5LL7tIk6c4mAzRKUC991gTXwTVdvPC5rLn/PSYSmCOVv2djvZYhM8pGVSjQCjNH/OXqurKq0MMOdnplM+t4N0FECmZPVbVtig4FcG8uxPmU6/RzjnbRYwaTUP6wtmO6udLjyGkdT7SKcOvWG0eAgqsJRx1gpUSqv02m9+v4YPmHwhpaO/Vo55E/Ruq5ctvs8C90CYZliu6jFk3C/+qIgUTAstICHqc3xq4HrXFHuvMI/He9p8+UQVG4T2EUyCES7gemue5H77OxLlZTrCmsNUeQharhBR/BM0vHhJgV2o8KIM0eEgf8OZdw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8198.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(2906002)(4326008)(8936002)(83380400001)(508600001)(6666004)(6506007)(6512007)(26005)(86362001)(52116002)(55236004)(5660300002)(38100700002)(8676002)(6486002)(316002)(186003)(2616005)(1076003)(36756003)(66946007)(66556008)(66476007)(38350700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?fegMZ4/INaC9rGxFbBqy1szlB/2yso6CfVaGcR3IZzx+1GWAe2YNREv6tQcS?= =?us-ascii?Q?Fsxc5c3LufmU7L2cbr7K0dTIaFKoOwvNnJo+kCMRdEg2s0T4uOm8BzJwTshw?= =?us-ascii?Q?1xIxMXq73/DglN99nlxmfXvKLUkGn39s+D8c+95awbB28KRroM9jZkcDDDba?= =?us-ascii?Q?tU7Y3a4/GY/BqVeP5d2pM8it5AkIQladqly1WJV5YdNZ8/NkphU7bdEZvcQu?= =?us-ascii?Q?mKqbaXYkCTe+GK2w2StvqgWbsF0LgWFOLHL0Jlq6E03sv1grRh1T5j6pFTzJ?= =?us-ascii?Q?FmLvIfzvHT9zpqU7y4X8z4lpoLSw1Q5BB5Z9uFLmp+wpbP2ULC4oY3QbZXFE?= =?us-ascii?Q?smi0kioA7BSDP1yafMf1R85wpHZ10luBpsDldKK6m5VpefKwgnK0+zWdVROo?= =?us-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d048XTh0Km/rO1nS/0gR7HwSBZnmVsS?= =?us-ascii?Q?j9Bs4Gsy9k6LgH4iRpEdTwO3tKkRB29oXO7c3jj85GSfaptIt62sSYHks3iH?= =?us-ascii?Q?S20pR9tUMlnzu1bA17ZmfnvzYIYvkY32zazqm3z3g/l2wpTETV47tnJwVYlv?= =?us-ascii?Q?cnCu9yGds0pU8pnYrcmLvrU0YLf4kUlOoJoaJm/FuF1vfe2yG2SFfE+zKMXj?= =?us-ascii?Q?jH3NFl3boLerLH4h2ezFINuUV8NUPQJPOEnZem1q9N+bBZyaFl+ULmNzXE/Z?= =?us-ascii?Q?idCcOAyF+r0ANQj1KbEy97rpBdCQ4BDNE1TS85uauJZqtsy85sZ6Y+sJSs5q?= =?us-ascii?Q?FUzkgbNXu8YTz+wJD+lygQQh1Y3JobG7b7r9DVWoSc3N9uzyTcqDnw98Bs13?= =?us-ascii?Q?EB8NsyutlBsMpYrmGKkdDADAPu6qJVPYuyXm7roM+0krgn2+yP/cBLZylGEh?= =?us-ascii?Q?eGuKpNt8Fg=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5b25896-788c-4e0a-ee20-08da290cf167 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8198.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2022 11:47:59.8298 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qeEjeuQLBPj9Is0cm5m06t4vuRNARZvWP73Y26w1CyvzIPAsea+ZtqFZFeQqJzpL X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4622 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 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") Cc: stable@dpdk.org Signed-off-by: Gagandeep Singh --- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 35 ++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index e62d04852b..03fef5e500 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-2021 NXP + * Copyright 2016-2022 NXP * */ @@ -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; +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, @@ -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, 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.25.1