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 38B6343254 for ; Tue, 31 Oct 2023 14:56:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 322D440691; Tue, 31 Oct 2023 14:56:31 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2040.outbound.protection.outlook.com [40.107.22.40]) by mails.dpdk.org (Postfix) with ESMTP id 6DC9040284; Tue, 31 Oct 2023 14:56:29 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oAB3b7CKcg3IhcTOZe2s4EjneqFsdoBkOgbLTZYjN6AQFy0fyNiD6YAzmQ96slBoX40lGLpzV5CKIDKsnPyWx7j3kVlFTVBtUX4fUzRJCiB6oG02+/FSSuSF+l+3c2H3h8aunFozhbhv+OtsfPoavv54v7kOpcIEsAMeMRcFcD9sqQ5tTTT6V7QJ2FwNbOvGJ0RCQA4eLYWQARREthmPXn40aE/byjBgPty6c8XI8O+MglZCi07nccbRPBYui60gg0a+YUcPeX+I0dG5vi82iHP5O3r2SH69to7YfR0dpbEw5IYX8R+EqnjidU/mhWOEuBU3h4NRcfXzREgJWE7yRA== 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=eNiJSg8ozrsZ4/TDcSTNAcFj2sVYhewad7LDaaSLQhs=; b=hSVSp4sTA3nQiKEQNY2tyPt9kT9bs//NfRAJmEUHM9aqCsL0kEEnRw+rEwDzBzo0CV8hh4Z8VPYdXk26CRjoxbKXSK4JephlrH2d4kBwwDBOfJvkPPZQojMW/ZI+RTn3HjsKlXSvXtRW8PY+aRzg/4NWGARIocmMWKoeXHqY0GvgbJ8qGGiriKgqp9rDuDDxUL8LBLk2NmRkMpB2md42RM2F06yY20ogqFxUgjCvPZHd74VJJBZh27zjGOw8k9daj+32P/mGQNWVBkF+QTxcXmYveixtLxAPRehFU4rnsswmFq4QAyKVc9/ZI8oLEJVYtWMDfDdPKK4jF3qDXi5mQQ== 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=eNiJSg8ozrsZ4/TDcSTNAcFj2sVYhewad7LDaaSLQhs=; b=dAjGMISDAO9/3XpApW3Vh1hFYhwbt8SeA8329GTuv+m8T6UnbH8IsgxinAOFwJJ5rkkflSPyCK7WRjXYxFdbChbddX7EQ4NfdFkZZ8XtTL7aDwzjVU1iBP95ltk9QmuUPfVWNKDqL4UE6XnisNMpgQJr6AVWavJb5SZtdC0NrNY= Received: from PAXPR04MB9328.eurprd04.prod.outlook.com (2603:10a6:102:2b6::15) by AM8PR04MB7283.eurprd04.prod.outlook.com (2603:10a6:20b:1c7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.18; Tue, 31 Oct 2023 13:56:27 +0000 Received: from PAXPR04MB9328.eurprd04.prod.outlook.com ([fe80::6634:da34:8424:50b5]) by PAXPR04MB9328.eurprd04.prod.outlook.com ([fe80::6634:da34:8424:50b5%4]) with mapi id 15.20.6954.017; Tue, 31 Oct 2023 13:56:27 +0000 From: Hemant Agrawal To: Akhil Goyal , "dev@dpdk.org" CC: "stephen@networkplumber.org" , "vattunuru@marvell.com" , "stable@dpdk.org" Subject: RE: [PATCH v2] test/security: fix buffer leaks in error path Thread-Topic: [PATCH v2] test/security: fix buffer leaks in error path Thread-Index: AQHaC8XEEpZq8uwPBUe68N3zVhMcsbBj6puQ Date: Tue, 31 Oct 2023 13:56:27 +0000 Message-ID: References: <20230822173316.465078-1-gakhil@marvell.com> <20231031064446.150191-1-gakhil@marvell.com> In-Reply-To: <20231031064446.150191-1-gakhil@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PAXPR04MB9328:EE_|AM8PR04MB7283:EE_ x-ms-office365-filtering-correlation-id: e6d6735d-b516-4e6d-280d-08dbda192d9d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: YYrQki9QcRolQROTMqlvO3THSC8aUEed9QMuigv6YulnuySSYjbBv7fW0xeRz+efRMtXhKFwXI+vyTrWO+ZpD1qvi+4a2q152UC89TIJ5KT6vjFy1m1wyA+QIvXt8f5SDQxCFrC0cne03QACQTUZxA4oLALS+UDg6Sge7U3fGejpgtr/UCWycRbLoMc5Bk+R2WxriI2QvuEZ4SXWcuBc0Al/PzdpaIrkOXPzG+WilSRQCiD8wbPgaqnYvYd64+5EHzP/K347SHJ1lJ2al+bc1fn+4z5sZ5566AGT1msFSI8LH2H1a4ATBwXzFduZAWkwaaCRLIMJ988Vq6srW1PLsZ0hiGLgyX3ZjRfHjtZk0poTFjOVTyClIeF0QC94/6jvSndFAzK9dBXYr7n5ztEsocevf/cO4xN0zA5z7GXjEA5olWHSRAMtukUhIvL+sXGWRfXplOujdMJrCXIT6mJTa4mNvvUbrvBVPURehiULd/Ev1Jp6RpRgWB2qjcntgrlsh3veJZeaBZfRu89Le52nelPpu7oxRwg9rIpBvKCtDraxlbZrvkaaPYQI+2M7UIecWth9yM89HR3zZNaFPkDSmJbY2ajTvNlOP3rgMbpBRdLWasAdEXRynTlhACli29VQ x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB9328.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(39860400002)(376002)(346002)(366004)(396003)(230922051799003)(64100799003)(1800799009)(186009)(451199024)(83380400001)(26005)(38100700002)(316002)(76116006)(110136005)(66946007)(54906003)(64756008)(66446008)(66476007)(66556008)(5660300002)(52536014)(4326008)(8936002)(44832011)(8676002)(6506007)(53546011)(55236004)(15650500001)(7696005)(9686003)(2906002)(41300700001)(478600001)(71200400001)(122000001)(86362001)(33656002)(38070700009)(55016003); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?DmMJ9+cNPRBlhBJy9I43anpYBhg9eW6b6Wigpp5M2EBksTcxqUPjWZyPktN6?= =?us-ascii?Q?k7jxWW++BPZMWxHw77HMC1C7wFM7QX2mHmvlPBLMnka/BaKGq8V0+A4beK73?= =?us-ascii?Q?QTsJMy6Jtg52uOhmurhin7jiHucINmyfFGOP+JMAMXXUEZKi3c4P3viDGpuq?= =?us-ascii?Q?IXS31EQhS4iHgMnSvXfaz+UPDzqEPLsk7EHUW/avn+nvmDt/FGNARDpQI+Lf?= =?us-ascii?Q?0lECGCV9ngM4KEL1+G02pf3qJP3IbHaSfc3Dbii71XtEGskYRs4el1GZzREi?= =?us-ascii?Q?i+FsBLAyRIjxtbUC8EDJSrqUk7AiPFC9PuIa+GvvJLYTRWEz4tkGhNAgnNff?= =?us-ascii?Q?aQZ1SUIlCRXkCYKr/8nsT2jrtsTv2WRK2IbXMU41SsR6hH+SkdliTIpBRuep?= =?us-ascii?Q?iMnjp5tBP3uCbmM54ga4+c/BWxglmTKp988Q/oTE9UtMMzOm+jKKfVwGmz56?= =?us-ascii?Q?zHHIT3FTIwHhbGHIoYcpqozi81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yvvMNhpw1cOznMYdW8DEUPzDR4y+zeuNSG79Dh4Vv2zXa3nC5?= =?us-ascii?Q?DhTaeDKVeuDftMmyDEwxrVNsQ/cH2TOertAgZ8Lw4Y7BvX/TnbY4YIpb5xWZ?= =?us-ascii?Q?O5dg2aSibPXy5l0Pk+1Ghdq2Bzo5hVdPTfk0w33DE51pv5JCPg5fKdNtB4yC?= =?us-ascii?Q?7/sMG+M9oagmAOHfV2GT6GgGr5DFIV3htx2XnnfA?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9328.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6d6735d-b516-4e6d-280d-08dbda192d9d X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Oct 2023 13:56:27.6859 (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: wfNZbxizVc6Kv1fTWtsXyDiloYg5KK8qjgRg9l0lV4irB0k3PNqf0NBh8N2tVNtrv68+9puvmkASFYv2niDa/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7283 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 Acked-by: Hemant Agrawal > -----Original Message----- > From: Akhil Goyal > Sent: Tuesday, October 31, 2023 12:15 PM > To: dev@dpdk.org > Cc: stephen@networkplumber.org; Hemant Agrawal > ; vattunuru@marvell.com; Akhil Goyal > ; stable@dpdk.org > Subject: [PATCH v2] test/security: fix buffer leaks in error path > Importance: High >=20 > In case of failure of a test in macsec autotest, the buffers were not get= ting > cleaned. > Added appropriate code to clean the buffers. >=20 > Fixes: 993ea577a006 ("test/security: add inline MACsec cases") > Cc: stable@dpdk.org >=20 > Signed-off-by: Akhil Goyal > --- > - Used rte_pktmbuf_free_bulk as suggested by Stephen. >=20 > app/test/test_security_inline_macsec.c | 65 +++++++++++++++++--------- > 1 file changed, 44 insertions(+), 21 deletions(-) >=20 > diff --git a/app/test/test_security_inline_macsec.c > b/app/test/test_security_inline_macsec.c > index 59b1b8a6a6..f11e9da8c3 100644 > --- a/app/test/test_security_inline_macsec.c > +++ b/app/test/test_security_inline_macsec.c > @@ -952,8 +952,7 @@ test_macsec(const struct mcs_test_vector *td[], > enum mcs_op op, const struct mcs > tx_pkts_burst[j]->ol_flags |=3D > RTE_MBUF_F_TX_MACSEC; > } > if (tx_pkts_burst[j] =3D=3D NULL) { > - while (j--) > - rte_pktmbuf_free(tx_pkts_burst[j]); > + rte_pktmbuf_free_bulk(tx_pkts_burst, j); > ret =3D TEST_FAILED; > goto out; > } > @@ -965,8 +964,7 @@ test_macsec(const struct mcs_test_vector *td[], > enum mcs_op op, const struct mcs > opts->ar_td[k]->secure_pkt.data, > opts->ar_td[k]->secure_pkt.len); > if (tx_pkts_burst[j] =3D=3D NULL) { > - while (j--) > - > rte_pktmbuf_free(tx_pkts_burst[j]); > + > rte_pktmbuf_free_bulk(tx_pkts_burst, j); > ret =3D TEST_FAILED; > goto out; > } > @@ -993,8 +991,7 @@ test_macsec(const struct mcs_test_vector *td[], > enum mcs_op op, const struct mcs > tx_pkts_burst[j]->ol_flags |=3D > RTE_MBUF_F_TX_MACSEC; > } > if (tx_pkts_burst[j] =3D=3D NULL) { > - while (j--) > - rte_pktmbuf_free(tx_pkts_burst[j]); > + rte_pktmbuf_free_bulk(tx_pkts_burst, j); > ret =3D TEST_FAILED; > goto out; > } > @@ -1016,7 +1013,9 @@ test_macsec(const struct mcs_test_vector *td[], > enum mcs_op op, const struct mcs > id =3D rte_security_macsec_sa_create(ctx, > &sa_conf); > if (id < 0) { > printf("MACsec SA create > failed : %d.\n", id); > - return TEST_FAILED; > + > rte_pktmbuf_free_bulk(tx_pkts_burst, j); > + ret =3D TEST_FAILED; > + goto out; > } > rx_sa_id[i][an] =3D (uint16_t)id; > } > @@ -1025,6 +1024,8 @@ test_macsec(const struct mcs_test_vector *td[], > enum mcs_op op, const struct mcs > id =3D rte_security_macsec_sc_create(ctx, &sc_conf); > if (id < 0) { > printf("MACsec SC create failed : %d.\n", id); > + rte_pktmbuf_free_bulk(tx_pkts_burst, j); > + ret =3D TEST_FAILED; > goto out; > } > rx_sc_id[i] =3D (uint16_t)id; > @@ -1032,19 +1033,26 @@ test_macsec(const struct mcs_test_vector *td[], > enum mcs_op op, const struct mcs > /* Create Inline IPsec session. */ > ret =3D fill_session_conf(td[i], port_id, opts, > &sess_conf, > RTE_SECURITY_MACSEC_DIR_RX, > rx_sc_id[i], tci_off); > - if (ret) > - return TEST_FAILED; > - > + if (ret) { > + rte_pktmbuf_free_bulk(tx_pkts_burst, j); > + ret =3D TEST_FAILED; > + goto out; > + } > rx_sess[i] =3D rte_security_session_create(ctx, > &sess_conf, > sess_pool); > if (rx_sess[i] =3D=3D NULL) { > printf("SEC Session init failed.\n"); > - return TEST_FAILED; > + rte_pktmbuf_free_bulk(tx_pkts_burst, j); > + ret =3D TEST_FAILED; > + goto out; > } > ret =3D create_default_flow(td[i], port_id, > RTE_SECURITY_MACSEC_DIR_RX, > rx_sess[i]); > - if (ret) > + if (ret) { > + rte_pktmbuf_free_bulk(tx_pkts_burst, j); > + ret =3D TEST_FAILED; > goto out; > + } > } > if (op =3D=3D MCS_ENCAP || op =3D=3D MCS_ENCAP_DECAP || > op =3D=3D MCS_AUTH_ONLY || op =3D=3D > MCS_AUTH_VERIFY) { @@ -1057,7 +1065,9 @@ test_macsec(const struct > mcs_test_vector *td[], enum mcs_op op, const struct mcs > id =3D rte_security_macsec_sa_create(ctx, &sa_conf); > if (id < 0) { > printf("MACsec SA create failed : %d.\n", id); > - return TEST_FAILED; > + rte_pktmbuf_free_bulk(tx_pkts_burst, j); > + ret =3D TEST_FAILED; > + goto out; > } > tx_sa_id[i][0] =3D (uint16_t)id; > tx_sa_id[i][1] =3D MCS_INVALID_SA; > @@ -1071,6 +1081,8 @@ test_macsec(const struct mcs_test_vector *td[], > enum mcs_op op, const struct mcs > id =3D rte_security_macsec_sa_create(ctx, > &sa_conf); > if (id < 0) { > printf("MACsec rekey SA create > failed : %d.\n", id); > + > rte_pktmbuf_free_bulk(tx_pkts_burst, j); > + ret =3D TEST_FAILED; > goto out; > } > tx_sa_id[i][1] =3D (uint16_t)id; > @@ -1080,6 +1092,8 @@ test_macsec(const struct mcs_test_vector *td[], > enum mcs_op op, const struct mcs > id =3D rte_security_macsec_sc_create(ctx, &sc_conf); > if (id < 0) { > printf("MACsec SC create failed : %d.\n", id); > + rte_pktmbuf_free_bulk(tx_pkts_burst, j); > + ret =3D TEST_FAILED; > goto out; > } > tx_sc_id[i] =3D (uint16_t)id; > @@ -1087,19 +1101,26 @@ test_macsec(const struct mcs_test_vector *td[], > enum mcs_op op, const struct mcs > /* Create Inline IPsec session. */ > ret =3D fill_session_conf(td[i], port_id, opts, > &sess_conf, > RTE_SECURITY_MACSEC_DIR_TX, > tx_sc_id[i], tci_off); > - if (ret) > - return TEST_FAILED; > - > + if (ret) { > + rte_pktmbuf_free_bulk(tx_pkts_burst, j); > + ret =3D TEST_FAILED; > + goto out; > + } > tx_sess[i] =3D rte_security_session_create(ctx, > &sess_conf, > sess_pool); > if (tx_sess[i] =3D=3D NULL) { > printf("SEC Session init failed.\n"); > - return TEST_FAILED; > + rte_pktmbuf_free_bulk(tx_pkts_burst, j); > + ret =3D TEST_FAILED; > + goto out; > } > ret =3D create_default_flow(td[i], port_id, > RTE_SECURITY_MACSEC_DIR_TX, > tx_sess[i]); > - if (ret) > + if (ret) { > + rte_pktmbuf_free_bulk(tx_pkts_burst, j); > + ret =3D TEST_FAILED; > goto out; > + } > } > } >=20 > @@ -1116,6 +1137,7 @@ test_macsec(const struct mcs_test_vector *td[], > enum mcs_op op, const struct mcs >=20 > rte_pause(); >=20 > + j =3D 0; > /* Receive back packet on loopback interface. */ > do { > nb_rx +=3D rte_eth_rx_burst(port_id, 0, @@ -1129,8 +1151,7 > @@ test_macsec(const struct mcs_test_vector *td[], enum mcs_op op, > const struct mcs > if (nb_rx !=3D nb_sent) { > printf("\nUnable to RX all %d packets, received(%i)", > nb_sent, nb_rx); > - while (--nb_rx >=3D 0) > - rte_pktmbuf_free(rx_pkts_burst[nb_rx]); > + rte_pktmbuf_free_bulk(rx_pkts_burst, nb_rx); > ret =3D TEST_FAILED; > if (opts->check_sectag_interrupts =3D=3D 1) > ret =3D TEST_SUCCESS; > @@ -1154,7 +1175,9 @@ test_macsec(const struct mcs_test_vector *td[], > enum mcs_op op, const struct mcs > id =3D rte_security_macsec_sa_create(ctx, &sa_conf); > if (id < 0) { > printf("MACsec SA create failed : %d.\n", id); > - return TEST_FAILED; > + rte_pktmbuf_free_bulk(rx_pkts_burst, > nb_rx); > + ret =3D TEST_FAILED; > + goto out; > } > tx_sa_id[0][0] =3D (uint16_t)id; > break; > -- > 2.25.1