From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5225EA04E7; Mon, 2 Nov 2020 20:55:28 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3473F2C16; Mon, 2 Nov 2020 20:55:27 +0100 (CET) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130082.outbound.protection.outlook.com [40.107.13.82]) by dpdk.org (Postfix) with ESMTP id 6F5FC2C01 for ; Mon, 2 Nov 2020 20:55:24 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gzGb7jeyM40xSVBByWfj3GSgKtRhIE1SaxWCgIF+HfoAAuod5KplYuTT71F8zps0V5DU7njuQRen4eXUbiZnbocEPpi5cGgZFcCvSxKyzoB2T2ox1xeSuMgUCPxybOt9hJuv4/EWeH2nA15yDUdSEle4qMskLJtlg4sguMlT4prnW/cJnVLpO/h9MTwQYQJbIx5sYn7UIlpibcziPBwEn9p/k2BqYJpwUU0R8V/TS9Pn00/GaWre9o1NhcssOOwOy1EUsXRvQHkRylRoNJmLqodGavoQCDxuYcPws3LJRovDHEx3mEKb3UrQfnay5RBPHFuR6bpKDs/aGv+VsLlWIg== 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-SenderADCheck; bh=3mUZLWVIVjBxAQim5AcimQLuY02rqtmW+UjjhaA4r1U=; b=eVquq61qnP22RZ7HlD+T/SU0RE0tGZH7xUxW/2ChtBaU0UfVBDMcamL5Uv+5qDDquEIr8LFZkImeuTxiLSziK850NxIf1dYk0NIDsdznr0zedIKK1m+gW49xxAjwh6MSqZ+ACHnUYlydfGaQEHmic5f0A+3BBesS8noafQERAVgXa8M0KLLJg/ep8eWwxf5EMD2HJ4RRgpwUa//B7pYoJQKXmqmT4BTDTO8ow0HBy5DAkHuJnsxsOK+70TY3x0YLNrNAOISiBmcJCPPw39XRnLPJxqfHjsS9N9E/6rHGW3JK3qHI7A+vfN8coKJOCk5zWO+9+d9+ttOe0v4S/nGLOQ== 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=3mUZLWVIVjBxAQim5AcimQLuY02rqtmW+UjjhaA4r1U=; b=rloQQTszz9ZLiYfsa4W1c/uyv/tuYDUrlCM+4AYIEI0kA3NpFd596ak5L0FxkFxS3n66UF2EvYxgjdlOompJ3RHGic55miAh1UptxdqTm/GirWJA/E4FnqYpGaC3768uIKJlQnjELGKMXr4EEhhcjO6FIJGrcArg/cZEAX6kwvU= Received: from VI1PR04MB3168.eurprd04.prod.outlook.com (2603:10a6:802:6::10) by VI1PR04MB4333.eurprd04.prod.outlook.com (2603:10a6:803:49::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.28; Mon, 2 Nov 2020 19:55:21 +0000 Received: from VI1PR04MB3168.eurprd04.prod.outlook.com ([fe80::9513:3b55:931f:216e]) by VI1PR04MB3168.eurprd04.prod.outlook.com ([fe80::9513:3b55:931f:216e%4]) with mapi id 15.20.3499.030; Mon, 2 Nov 2020 19:55:21 +0000 From: Akhil Goyal To: Ciara Power , "dev@dpdk.org" CC: "roy.fan.zhang@intel.com" , Declan Doherty Thread-Topic: [dpdk-dev] [PATCH] test/crypto: fix null dereference for crypto op Thread-Index: AQHWrr43l52krVoyxk2FK+9AO6KX9am1RFfQ Date: Mon, 2 Nov 2020 19:55:21 +0000 Message-ID: References: <20201030131126.222553-1-ciara.power@intel.com> In-Reply-To: <20201030131126.222553-1-ciara.power@intel.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=nxp.com; x-originating-ip: [171.50.183.179] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: d9ee8993-2b82-4ee8-e9bb-08d87f693b44 x-ms-traffictypediagnostic: VI1PR04MB4333: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: JVWTXaV3s0uKDQrZ4coouSE/gt6BVfMNmvH7jGdI0t701ks3jHFn/sAavMcWH9DU9VWLGp0NDPJMfbN931LEK6QsxRsqq7jCCBczPYbjGWErHYlC/huhdYZh6ZaiAxWEoiF6VXQ9nnkA5kQuaLKGcppb2IeJtlT3KPbeZZ6oeXDS8Q2YrHl+ENUK6GhK58LuNnf85Jq9zuXDNgyFmnG3gbwKIjbHb3ritUMDGp41AxsMMMomOks/h48Ho+W+A0eYaki8yWRbQexJlxrb0Vkmv56uEGjXs0KVTJOopMH++vB7HA117Df2VeIWyC3+5F03 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB3168.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(396003)(366004)(39850400004)(346002)(376002)(44832011)(54906003)(2906002)(186003)(9686003)(8676002)(86362001)(5660300002)(316002)(7696005)(71200400001)(4326008)(110136005)(8936002)(83380400001)(66946007)(6506007)(55016002)(64756008)(66476007)(26005)(33656002)(76116006)(66556008)(66446008)(52536014)(478600001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: 0BFet4ul9S9ZSIrz3EZsjgG1+xClQnixsIO1f/ToO+YbMzZOCjrojpF4uryAvsjKKlzBaR4ffAVl7O6Umm1G/MJ1gkwGW21dfZiu+gJuMiq4VemnMAJ8Knn7+k14ZqXg0m0uvd/a/aY4PQ3jKqZAi/HkKJbtUzQMoCrRKNh865OEXVH1zQNCfHCl6gK+KSExnHgbyz9RVGey6149qDiOCVjm6ilZdy4o5ly6G36JulOCbSkkMtlC2qTVeVmr8/pM6FmI1i7ktpUCoOthHDNsdgfZi9Fh1uIIEGrF0XX5Q6nTY+U5C83rM+234FI4SXujXUhS+XdLulpdsG6WooOayfHBR4suc+YDrpcSst59cLhPqZNCRwYDEiz5by1GFv+SG2AE32tBKSg2JZC0HlyMVbKW5pN0NMhVdqdpE/0l2K0tvWuGTdg/veQ3DdtZfI5+cUFf3zXhbkOg82WrPCNZJvudXQTJlYFMRU3dWTIhFWB46Vr3cKPQAZPR4Ysoxz/z+lYqxlXgb83Lpn34vv4PTftlfg7ZJjEr8u0mLnil8LisuHM/fc67jL2wTnC8r4sSYwlL7+sN4jyoAcW/KIiWgbdXY5snM51VnwZn20NlmriRGBK14BpDHtxWP82u4yOxFQzsC3DPTQB139JTnh7JQQ== x-ms-exchange-transport-forked: True 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: VI1PR04MB3168.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d9ee8993-2b82-4ee8-e9bb-08d87f693b44 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Nov 2020 19:55:21.4541 (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: glJdtN/tDNY/PKHs6hRHJcS3o/WGUfjsSIwMNEPhXugG82nnVzxoPnesz1C0Fi2mInh/vA7fe4oOqOV5OtHunA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4333 Subject: Re: [dpdk-dev] [PATCH] test/crypto: fix null dereference for crypto op X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > Subject: [dpdk-dev] [PATCH] test/crypto: fix null dereference for crypto = op >=20 > In two test cases, the op value is set by the return of the > process_crypto_request function, which may be NULL. The op->status > value was checked afterwards, which was causing a dereference issue. >=20 > To fix this, a temporary op variable is used to hold the return > from the process_crypto_request function, so the original op->status > can be checked after the possible NULL return value. > The original op value is then set to hold the temporary op value. >=20 > Coverity issue: 363465 > Coverity issue: 363452 > Fixes: 4868f6591c6f ("test/crypto: add cases for raw datapath API") > Cc: roy.fan.zhang@intel.com >=20 > Signed-off-by: Ciara Power > --- > app/test/test_cryptodev.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) >=20 > diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c > index 0fed124d3a..ce8bcd1d4f 100644 > --- a/app/test/test_cryptodev.c > +++ b/app/test/test_cryptodev.c > @@ -6676,6 +6676,7 @@ test_mixed_auth_cipher(const struct > mixed_cipher_auth_test_data *tdata, > unsigned int ciphertext_len; >=20 > struct rte_cryptodev_info dev_info; > + struct rte_crypto_op *op; >=20 > /* Check if device supports particular algorithms separately */ > if (test_mixed_check_if_unsupported(tdata)) > @@ -6771,17 +6772,17 @@ test_mixed_auth_cipher(const struct > mixed_cipher_auth_test_data *tdata, > if (retval < 0) > return retval; >=20 > - ut_params->op =3D process_crypto_request(ts_params->valid_devs[0], > - ut_params->op); > + op =3D process_crypto_request(ts_params->valid_devs[0], ut_params- > >op); >=20 > /* Check if the op failed because the device doesn't */ > /* support this particular combination of algorithms */ > - if (ut_params->op =3D=3D NULL && ut_params->op->status =3D=3D > + if (op =3D=3D NULL && ut_params->op->status =3D=3D > RTE_CRYPTO_OP_STATUS_INVALID_SESSION) { > printf("Device doesn't support this mixed combination. " > "Test Skipped.\n"); > return -ENOTSUP; > } I believe the original check was also good. But instead of=20 if (ut_params->op =3D=3D NULL && ut_params->op->status =3D=3D RTE_CRYPTO_OP= _STATUS_INVALID_SESSION) it should be if (ut_params->op =3D=3D NULL || ut_params->op->status =3D=3D RTE_CRYPTO_OP= _STATUS_INVALID_SESSION) In this way the coverity should not raise an issue for this. What say? > + ut_params->op =3D op; >=20 > TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); >=20 > @@ -6872,6 +6873,7 @@ test_mixed_auth_cipher_sgl(const struct > mixed_cipher_auth_test_data *tdata, > uint8_t digest_buffer[10000]; >=20 > struct rte_cryptodev_info dev_info; > + struct rte_crypto_op *op; >=20 > /* Check if device supports particular algorithms */ > if (test_mixed_check_if_unsupported(tdata)) > @@ -6976,17 +6978,17 @@ test_mixed_auth_cipher_sgl(const struct > mixed_cipher_auth_test_data *tdata, > if (retval < 0) > return retval; >=20 > - ut_params->op =3D process_crypto_request(ts_params->valid_devs[0], > - ut_params->op); > + op =3D process_crypto_request(ts_params->valid_devs[0], ut_params- > >op); >=20 > /* Check if the op failed because the device doesn't */ > /* support this particular combination of algorithms */ > - if (ut_params->op =3D=3D NULL && ut_params->op->status =3D=3D > + if (op =3D=3D NULL && ut_params->op->status =3D=3D > RTE_CRYPTO_OP_STATUS_INVALID_SESSION) { > printf("Device doesn't support this mixed combination. " > "Test Skipped.\n"); > return -ENOTSUP; > } > + ut_params->op =3D op; >=20 > TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); >=20 > -- > 2.25.1