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 7CA34A04DE; Fri, 30 Oct 2020 14:11:38 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5D1E9C934; Fri, 30 Oct 2020 14:11:37 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 32294C920 for ; Fri, 30 Oct 2020 14:11:35 +0100 (CET) IronPort-SDR: kF5DdZUa+7G9C9BKAHuSM9OSU60K45h64ZDF7+fGJcDKqh+hTQSFA/w5e49T+VXBTCnY6/hWdY xQKo7CSZ9Hug== X-IronPort-AV: E=McAfee;i="6000,8403,9789"; a="148457956" X-IronPort-AV: E=Sophos;i="5.77,433,1596524400"; d="scan'208";a="148457956" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2020 06:11:31 -0700 IronPort-SDR: YELDKVOBtoG04HrRySoehQx0fEufK4MPbT+PSVmE+DhsFEbtB+99yrMDBURQ0aufNVftsFBLbQ ec1FgEyCnUuQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,433,1596524400"; d="scan'208";a="537061498" Received: from silpixa00400355.ir.intel.com (HELO silpixa00400355.ger.corp.intel.com) ([10.237.223.148]) by orsmga005.jf.intel.com with ESMTP; 30 Oct 2020 06:11:30 -0700 From: Ciara Power To: dev@dpdk.org Cc: Ciara Power , roy.fan.zhang@intel.com, Declan Doherty Date: Fri, 30 Oct 2020 13:11:26 +0000 Message-Id: <20201030131126.222553-1-ciara.power@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [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" 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. 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. Coverity issue: 363465 Coverity issue: 363452 Fixes: 4868f6591c6f ("test/crypto: add cases for raw datapath API") Cc: roy.fan.zhang@intel.com Signed-off-by: Ciara Power --- app/test/test_cryptodev.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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; struct rte_cryptodev_info dev_info; + struct rte_crypto_op *op; /* 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; - ut_params->op = process_crypto_request(ts_params->valid_devs[0], - ut_params->op); + op = process_crypto_request(ts_params->valid_devs[0], ut_params->op); /* Check if the op failed because the device doesn't */ /* support this particular combination of algorithms */ - if (ut_params->op == NULL && ut_params->op->status == + if (op == NULL && ut_params->op->status == RTE_CRYPTO_OP_STATUS_INVALID_SESSION) { printf("Device doesn't support this mixed combination. " "Test Skipped.\n"); return -ENOTSUP; } + ut_params->op = op; TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); @@ -6872,6 +6873,7 @@ test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata, uint8_t digest_buffer[10000]; struct rte_cryptodev_info dev_info; + struct rte_crypto_op *op; /* 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; - ut_params->op = process_crypto_request(ts_params->valid_devs[0], - ut_params->op); + op = process_crypto_request(ts_params->valid_devs[0], ut_params->op); /* Check if the op failed because the device doesn't */ /* support this particular combination of algorithms */ - if (ut_params->op == NULL && ut_params->op->status == + if (op == NULL && ut_params->op->status == RTE_CRYPTO_OP_STATUS_INVALID_SESSION) { printf("Device doesn't support this mixed combination. " "Test Skipped.\n"); return -ENOTSUP; } + ut_params->op = op; TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); -- 2.25.1