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 31733A0093 for ; Thu, 21 Apr 2022 14:01:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 152BA40040; Thu, 21 Apr 2022 14:01:03 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2053.outbound.protection.outlook.com [40.107.22.53]) by mails.dpdk.org (Postfix) with ESMTP id C786B40040 for ; Thu, 21 Apr 2022 14:01:01 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ys+9v16bLTLHZVBblJHkmOw13F1Wyb4WbU1hCYU35mBGc2mbhLqDoZH5fpZLw10j/0oLBIK5b3JkdltmjoxiCGt+rx8tvgKNEtSH+lmyl3wnQ0iBGJ5nGSGcv72vFOz6ewpyCtVYK8SYMI+M+w2kNJFu5iea8NMFFMWwyv9Rlho8sf6mbFsREoSkLHc9+vF18LpRPkKdB7wl2fmloKn8s+VabFLPo6dDPz7sqBuJWrxdcrTpwt7BHUBOCgSSQSvvgNME4+THK4qRpwok0+qFwA0KvV1BHLZ0LvY0+A27wHGWPEq0oCDGI1lqqwu/AgkrpVf55fzCIIcBHbaLeptS2w== 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=p+a7KecN5Z2EEVBEbz2aUJmdrDZ8vMxnooBIv/ddyZQ=; b=ZoRsjxvBum+wc8ij/YC4RvRJwBwUPrYoctOQhAasCTpZGATW46oThIivyNsXSXv8oA0osZT8yVxBRzeYePvoOmjjHF8WCojaPM9QLCvidg6O4pd6+fWGMp7joCi9C2OoXDB8Hg22zyiDWBKPSn3J8RIlgcPleQICxzUgI1nlRy8OITDwkYiorxShzuT1vQ1L6Z2a+BsYVJbcNArjiiJz+i1Ldt7iSyJOrJYbBKm5n0kdzb8pOWoQSG6yZFqneCS4/22eNUdDQqL4ZXyxs3yFJ0hXDaccThqmZbmKwmdqYIIDQm3KjLSEosO8tI39vT1X5NTCUFbzw/c46xju2mg8lg== 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=p+a7KecN5Z2EEVBEbz2aUJmdrDZ8vMxnooBIv/ddyZQ=; b=nxYCuhmZr06tkoDrJRht48ozJxJtbSyxfgpXAhZBuiMzGDc+AFYZn4ExLOb3fyP6g6TctlDQLTLcAF0a4aDprrNI3onx44aLahxX47xRGms8nCTOyxkQPtwIiuOhJ1PUjJSM/OWOmh7Q2ITIGv+khevcsa25vyB3JwJzUXi8cdw= 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 AM0PR0402MB3491.eurprd04.prod.outlook.com (2603:10a6:208:20::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.13; Thu, 21 Apr 2022 12:01:00 +0000 Received: from AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::8cf1:93b:c340:3be2]) by AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::8cf1:93b:c340:3be2%7]) with mapi id 15.20.5186.014; Thu, 21 Apr 2022 12:01:00 +0000 From: Gagandeep Singh To: dpdk-up@NXP1.onmicrosoft.com Cc: Gagandeep Singh , stable@dpdk.org Subject: [PATCH 01/15] crypto/dpaa2_sec: fix fle buffer leak Date: Thu, 21 Apr 2022 17:30:29 +0530 Message-Id: <20220421120043.2565227-1-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR04CA0167.apcprd04.prod.outlook.com (2603:1096:4::29) 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: c23bbcee-1d1c-493e-72f7-08da238e9a08 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3491: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: uJFTltuUw9iSXW0Nictavtywv/DxZJa3mHGottL8LU5qN1xgemjIpefCU4nyOD8w5YSEpFESkpHdwTBSfhYo6q3Blnn94R5DpCSSNeqX+EV8b6pFzANMaf4anBoL0D4WWBRs0L+DjmRB3i/v3hB5eQxi7ax4DcJw3JK6iyhnn3Hvs5sfWxDIiLGBoagNEv7HYOeXUBEqPaL1ARV418onpurBJgt+t1FK8tpbYHvZQN1+C1/Ib0OV55rbt6jmMgj5jtA1dm+J1DMPJ4cKEPbEUreFoBRr2+GN4ukNGsh5klsGdGlnHAoZBlZOjdxbxihv1fFMgYwOQqIPR0VUY8SZN3dZyLSclvnyPsD08V8WoJJIvgZZ6uL+Fkt59lcyXQiz+RYepC7o5P2PsaXvkQVpaQP61rsvADgq3883+d5oP5Ao1+JQqxRhBTkipQPrt8skcQRle5sF1ZLXmwEGhc5VpwIR6+Gva5sZepdXjzFfthoGexpv8vrV1V3BJb5eIeTuGKMfFKqhZlHJtw4KKf//F5KnvehttfZCemc14at9HAuE/sh4N6qG3vponAJAwMzxtLpIPf5YUZs5af68YiS1eiWz6W7d8Ac0XjUoeDSQnA5r75CGgfvw6vZDmlvMsZ1xHGJI1JkszZKih3CGcwYXOF/7gl2NJRyy1g0/WREjItHlh3AvOsLqwa3rrDSqItC4jAB/rwpZHbPtcJmGPyFJxQ== 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)(6512007)(2616005)(1076003)(6486002)(6506007)(6666004)(34206002)(52116002)(508600001)(55236004)(186003)(38100700002)(83380400001)(38350700002)(26005)(86362001)(36756003)(5660300002)(8936002)(316002)(4326008)(2906002)(66946007)(8676002)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?u18FBObvrIqBknTrxPFPuFMuWLjD43/VDeGqh5Mn8GLxJjrqAGi5i1Aa0Lo1?= =?us-ascii?Q?S2ZA2TYSTE1D7n7o8Wzx9hwyTJkbi5dlcEW8wv3ePLA7IQr9hm0q8tKcycpF?= =?us-ascii?Q?9Sr0BLFPVCtBGeGdnKx2gNDCCuXI5lj86sPzPrbeSDh9dznSYFNQ+GzvtkNV?= =?us-ascii?Q?VZcUsunixFqPrJl2OGIca12pDXVepDRt+Z+dHIFmGK6m1t5kJSTZhCci2/v5?= =?us-ascii?Q?PuvHJ/ESdIbq/XFydnoJ0SxBgW9q7a143KFdZ9dZ7ADKqdyeUtDn3/4m4AD5?= =?us-ascii?Q?lh5oj6i7IgjJPQLaUYlVtRW79kdu9wwZ5na+8bzT6b6lWNTVlr7bFwSWhVkj?= =?us-ascii?Q?oydTvrW/wT45cKuhjdi0aPyuswVmMmjdDSq1j3m8O6CLUSy8QrPv7T+cFvPb?= =?us-ascii?Q?elChzq04D/Lg0iN4raFpsW/FJp6A8yBx5x09T/J7jEXng/Qwnja9AFIIu1IN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7YRfJduK/o7L4SHFK3s3Ccv2t+80teFW?= =?us-ascii?Q?J2sIARFhPu8wnazNwdNQBd/bnCpq1z7nPTX2JPWtrO/2JAhVHjqSd5iznOTt?= =?us-ascii?Q?NWhHBjV+PekmR6CxCPDQ/jCF+eS+J2i/uT6yFzSRBrtwrp2NsMJHlTr3hYj5?= =?us-ascii?Q?0nhTVz+sHZthWG93LAVqWhloIC1LvWK6dftWtwJ6JK/4QUdmD3mF4WebHVq0?= =?us-ascii?Q?ZUbFmHSoSl+uqQAfKsfgyy48pQUXDF4mUoTLUtTdAxwkypCRhnEyD4NYW3lq?= =?us-ascii?Q?93YgJAf+AFHCM57nibCbvyIRX+zETWeAty6UbxpgY/y9KHyXEf3hnIGT++Fs?= =?us-ascii?Q?KS5HalCQHZxILZX0vcjwaFHaLobvtqyQqjWoEyASnzWe0zKAPORgaMiVy6tR?= =?us-ascii?Q?2nJh0n/XGg=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c23bbcee-1d1c-493e-72f7-08da238e9a08 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8198.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2022 12:01:00.5719 (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: U1vqEGApwJLUAiy4wJwoOQ6uBpk99ZHD/BhS/KTKpvmSbWCmZr2OGFjrueu43zA/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3491 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 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: b15cbf5b2d88 ("crypto/dpaa2_sec: fix fle buffer leak") 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