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 4F4F9A0093; Fri, 22 Apr 2022 05:51:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 16F3340042; Fri, 22 Apr 2022 05:51:38 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20073.outbound.protection.outlook.com [40.107.2.73]) by mails.dpdk.org (Postfix) with ESMTP id C68BF40040; Fri, 22 Apr 2022 05:51:36 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fOoWFPpgsUFQkshZDoW6bfBf5fjTZY+XTyza3JqQ8ADmYBJk4cJ/LzQFfsM5+6p32LI3J9R2k4NwfJGWtUIN12hrYQ4mR6pLTeJ+hdgTxjG3cynnt3ufSdfeakTCyh6NeAAfouqx9ScCxnuSAaiC8ymG4h2czEpph6vfPc+BJMfJseElOlKXersq3h6+20vZRM48Cg4J7DgJLfWWBAD9rvh9G2Qf6mZmmQ9FSmd+l9v4penYnk+OUJzD9IL7f8F7WSjdNgVWoW6QMC4+amCfcRcu0uYXtzXQ/M+vTCACPHye90WYIZ+Q1j+MaCLYQAujiTD6JgQZ9wlljPDy/1PVIA== 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=kXosvowix25zQYkW7mr4Rw5prVR821lukT4fAjQp+KECTLZouE6w6Jn4Dth3xPWLlFC8M7QD8fCpb6JWfmbedvmfrGL+93CBk/0xy/j4Bn4GtQjqwkLlK9+WbqlGlk+TkRLXY4UqKnjyj7p+yxlJajq/8JrUwgCi3iDV9N99Fgs4dqOG3XWi2x8GisbiQk9OL4xVrU5GYZqjMniru1qVE1g5zMpftqt+iKB5Nk+9jLDxP2yTMt36dpcmnI0eb7GWJeBcxnwrbQ7SX/cFEWCli3qnNOH/9hjpGnqWd4Wfk5TYLvPIPBU80JVUovZ58sLNAVQCoyWLjqxxXl2ZsBJ2kQ== 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=N6HYhzcrSK4WGELdwZPCxiH5rU/XGzvBAfGixZA8LcApws0o5k/UqWIfuG2irbJWfamlmM9vPYlONjG8otu7Fg2kd3v1fwVRllw6gxfrLI44muLEYl6yZgHls7Sq1h+m5nIZfe7WHW9mdjgX34jHABLAcG65hqMkj5uyTXvSiEA= 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 DB7PR04MB4393.eurprd04.prod.outlook.com (2603:10a6:5:32::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Fri, 22 Apr 2022 03:51:34 +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.015; Fri, 22 Apr 2022 03:51:34 +0000 From: Gagandeep Singh To: gakhil@marvell.com, dev@dpdk.org Cc: Gagandeep Singh , stable@dpdk.org Subject: [PATCH 01/14] crypto/dpaa2_sec: fix fle buffer leak Date: Fri, 22 Apr 2022 09:20:47 +0530 Message-Id: <20220422035100.3180870-1-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) 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: 4279f60f-8203-461b-24a2-08da241364e1 X-MS-TrafficTypeDiagnostic: DB7PR04MB4393: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: H20mqTMFElppTpYddWwXDCWyIbMY5NNffQgBVi5ZYsNjirmooS4mKp35GKQ61pdFenRLpVpUi3GYEiFpN3rJx938nLyeho90T21o8BhQjZQVSNtvYG4/fqlEt4iZVwaAEuEyVjwk5iq999fDofcOn0PlS2iQdfbJOk3Kv29Ev4Ly8hWfmVnpi+j1u6RXFHLc6p0DCn+LbGr+UtmPPRa/R6yCY6q22rOdGQIx8ToFKcYbirtIu+ejJE18YP/1DLLAGNPYhheVHCtfn/6XiGVgNP5BfgMQVUFQ6Yd2By//ypn7kS+XZmEK5H1XGuPITotsPbG2nwUuITCL0vMJ6aB1KlLxAi3WhdJSMsaSIOsoC59UDo5I88JHSOD9Z6mlZi/DLRXfKdSbUCAFkampdeyguiSPjfpwGPPBioqsg7xpsdlnbTCV1PWQ4H4r4BLJDeNbahDgfV/KCgP/lYxAwg8hdFvD+8CiPs/Kg6jQXKrbIEZyFgvuw3ffeCvO2HWHqhGJSASJIOK3QrzjBQl+5cD7yhzBYyU4Xa07Xyk0BlYBy310SjNed4x8Vc4KqpRNsWYaZN4tvFR85tyOOQvoktl9h/xfANT8Gv4ne8ofaaf+XmNxCXEF0IiTKlEtZPGgdXD1cqdkUCyaTKay4WcwljgIZhgPrtSKhpT5W+XRnv0Bw3Y/kgSl0q84Ec8sMNSpH6++rWmg5cyowOxPz84c7yag0g== 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)(5660300002)(36756003)(2616005)(6486002)(1076003)(8936002)(86362001)(316002)(52116002)(66946007)(26005)(6506007)(6512007)(186003)(66556008)(6666004)(66476007)(83380400001)(38350700002)(38100700002)(508600001)(4326008)(55236004)(2906002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?YIskaCMU41rj9l7ztHnf9zIpcceA5GVdrLp/PQEsVHCgu8PKDWYuaTc5pnCg?= =?us-ascii?Q?5OUXVdYgVBsqXhWAZi6OWJRjLh6XavOTEfUh3+mwq0ugOP1uQY5kfX/NTh3A?= =?us-ascii?Q?maMcg7QndvAsPFUU2BZ0OAshfR2Sr6BPhjWTtTHRnw7wH0IRpLSuk01Xrw2a?= =?us-ascii?Q?0j47PHEWJqy4YvCUCVSOGgrjiRN9AtweD0YbxqzVItBlbHkrNNWHOoBJ7FVh?= =?us-ascii?Q?LRNrfce6CXOt95kwWV+/mlo47TZn12Qs4s0l0iG+SffKmkdiU6JivqPD0x9I?= =?us-ascii?Q?DzshsdYVHJh6SAtC1t/SxSgEvwRDO6nsy6F/2zDq6eO1W38C4KFCsggrTsWR?= =?us-ascii?Q?o7g0xYlHvGxDrAk4X2iOWC87BUYg6kf3+oztrJkP33wknqdVffUa1Ajapj5t?= =?us-ascii?Q?yGSuGtdqjgJgVjB1EZDkCIFmfNtmn1OsLU/SAw9d10HdfJ5rniim4zUgMURF?= =?us-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jichIiEJe5JQVwSt9ByuJvO?= =?us-ascii?Q?ZHlseA3AlHeiFeNOzFxfrj3Cuz5zuXeaRarJMg3LjKRL970sYOOQ1hYR8aeI?= =?us-ascii?Q?0YxJ9TnRTYTXzuR6wckS0w8j8SDIwuO8vG/sseUctAtzLPpaz16u6VGiZzO2?= =?us-ascii?Q?mYACHRSQyT065YHkn2OjSp+XSO9UWhHk8efFutLNLC+tlcpw1vk1K1PRMqnz?= =?us-ascii?Q?uir6LBcKXUxinWxcJFBrlFeCGK1WaE7QRbeM7lbDbTc83t/k7vdimpKA2Tpc?= =?us-ascii?Q?NK2dsPLi6In0DrRt6B55FsxPfht+qVMl35vti69sHAGwMHoWP9t51T0mOQqg?= =?us-ascii?Q?jQv5RJl9ixdyT5a1D1IfXd68Vrix4I1olDN8/ftc2WOY1vAXvSktoTysb/fu?= =?us-ascii?Q?xxl5BVGKlg=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4279f60f-8203-461b-24a2-08da241364e1 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8198.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2022 03:51:34.5706 (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: BQSG/eodOBFGbPtnAwAjS0KAPASMSwYL3IqByYZZ+LxmhzE6ReG76ZQ7Q/OZcUQQ X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4393 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: 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