From patchwork Wed Jul 17 16:22:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 169151 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1182259ilk; Wed, 17 Jul 2019 09:24:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzziK5q9FmJQI4EAFEmpAGJI9DBfyzWNGf98uPA0QOM6zpxmu0c8YVSC6VQjeLewudFIh7E X-Received: by 2002:a50:d2d3:: with SMTP id q19mr35846090edg.64.1563380646006; Wed, 17 Jul 2019 09:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563380646; cv=none; d=google.com; s=arc-20160816; b=VUHQsz4RptH74XDJQeYqOy3bUF8ZyuBJVvvGSCkTNRs+27Ds907AYcZjIFDoQhOOmk MNo6g+qIw6TMoa9w9pXz0sUjr5ptIr++SVvkjMBeqJNfL34/redY5e1TIPv2gD7P7K4g aIK5A7Pf4Pc40n2SGDFZfz63akCMpkkR58+qy+YC5r4N8GZGIHHzJeyZedp/TERglOxg 2WkwlWHAfNYp8SFRIvSV49JQUhrPKdjaC4e6biDNl5X62MDKyvkuLT88OLZfuKR673bF fN2saN0qD3pXrQ2KfegPe1/XzFiiS8ZDKwQNO9KD4KpffTUl4FL8EbykyT0uIJK/IFl3 WBzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:message-id:date:to:from; bh=ESwtPcB52sIVKFcc3iduG5LUupmyW1AdImgua6HNiPI=; b=lwfDH5pr9CjmQwztkgenRKRfdxojG78IC1jmabbjVoqTZ/NbW5v8kozPbGNz62Rljb Zx4WueT78m5WtNyFVmdWTYlOdCSnh8bJ9ku7RX77D44eE2SKvyI/dXLOFsUzW3NO67TV hsulxgkwbiGq1UfHLvg5rcVNEj76/7Gjw1ECqrlUoox6KrmUyIHEoSEhxrcUKhC6v8iD diISOxDV2MzpcwTmkFaQd6CDWSces/MYQvrCNX5NenQpJQZgbGu/+SzsBSHvlR/mb3ae 7YIWSbSZieywefuoUHvFzq4LBOFhYWj8AM9+kucqtueVi6ppA7G2fR92qbELzfP6zBm2 r7EA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id j24si12944082ejt.212.2019.07.17.09.24.05; Wed, 17 Jul 2019 09:24:05 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BF2EF1BE27; Wed, 17 Jul 2019 18:24:03 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id 93D021B9AF for ; Wed, 17 Jul 2019 18:24:01 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 47309200123; Wed, 17 Jul 2019 18:24:01 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 52220200361; Wed, 17 Jul 2019 18:23:59 +0200 (CEST) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id BF3A1402CF; Thu, 18 Jul 2019 00:23:56 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org, akhil.goyal@nxp.com Date: Wed, 17 Jul 2019 21:52:41 +0530 Message-Id: <20190717162242.19689-1-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH 1/2] test/crypto: fix session init failure for wireless test 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" This patch add the support to handle the failure in session create for wireless related cases. Else it will cause segment fault due to I/O on un-initialized sessions. Fixes: b3bbd9e5f2659 ("cryptodev: support device independent sessions") Cc: stable@dpdk.org Signed-off-by: Hemant Agrawal --- app/test/test_cryptodev.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 05422daff..a7e93b706 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -2377,6 +2377,7 @@ create_wireless_algo_hash_session(uint8_t dev_id, enum rte_crypto_auth_algorithm algo) { uint8_t hash_key[key_len]; + int status; struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -2399,9 +2400,10 @@ create_wireless_algo_hash_session(uint8_t dev_id, ut_params->sess = rte_cryptodev_sym_session_create( ts_params->session_mpool); - rte_cryptodev_sym_session_init(dev_id, ut_params->sess, + status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, &ut_params->auth_xform, ts_params->session_priv_mpool); + TEST_ASSERT_EQUAL(status, 0, "session init failed"); TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); return 0; } @@ -2414,7 +2416,7 @@ create_wireless_algo_cipher_session(uint8_t dev_id, uint8_t iv_len) { uint8_t cipher_key[key_len]; - + int status; struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -2437,9 +2439,10 @@ create_wireless_algo_cipher_session(uint8_t dev_id, ut_params->sess = rte_cryptodev_sym_session_create( ts_params->session_mpool); - rte_cryptodev_sym_session_init(dev_id, ut_params->sess, + status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, &ut_params->cipher_xform, ts_params->session_priv_mpool); + TEST_ASSERT_EQUAL(status, 0, "session init failed"); TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); return 0; } @@ -2517,6 +2520,7 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id, { uint8_t cipher_auth_key[key_len]; + int status; struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -2554,10 +2558,11 @@ create_wireless_algo_cipher_auth_session(uint8_t dev_id, ut_params->sess = rte_cryptodev_sym_session_create( ts_params->session_mpool); - rte_cryptodev_sym_session_init(dev_id, ut_params->sess, + status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, &ut_params->cipher_xform, ts_params->session_priv_mpool); + TEST_ASSERT_EQUAL(status, 0, "session init failed"); TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); return 0; } @@ -2572,6 +2577,7 @@ create_wireless_cipher_auth_session(uint8_t dev_id, { const uint8_t key_len = tdata->key.len; uint8_t cipher_auth_key[key_len]; + int status; struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -2614,10 +2620,11 @@ create_wireless_cipher_auth_session(uint8_t dev_id, ut_params->sess = rte_cryptodev_sym_session_create( ts_params->session_mpool); - rte_cryptodev_sym_session_init(dev_id, ut_params->sess, + status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, &ut_params->cipher_xform, ts_params->session_priv_mpool); + TEST_ASSERT_EQUAL(status, 0, "session init failed"); TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); return 0; } @@ -2643,7 +2650,7 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id, uint8_t cipher_iv_len) { uint8_t auth_cipher_key[key_len]; - + int status; struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -2677,10 +2684,10 @@ create_wireless_algo_auth_cipher_session(uint8_t dev_id, ut_params->sess = rte_cryptodev_sym_session_create( ts_params->session_mpool); - rte_cryptodev_sym_session_init(dev_id, ut_params->sess, + status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, &ut_params->auth_xform, ts_params->session_priv_mpool); - + TEST_ASSERT_EQUAL(status, 0, "session init failed"); TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); return 0; From patchwork Wed Jul 17 16:22:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 169152 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1182393ilk; Wed, 17 Jul 2019 09:24:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxc7uLebEtjY09+nQp1QjCUcRtDkxezKTT90BkGbCkNBCjkqLb6FJ8QeZoljE/TM7m5X+c5 X-Received: by 2002:a17:906:b2c6:: with SMTP id cf6mr32815358ejb.274.1563380652526; Wed, 17 Jul 2019 09:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563380652; cv=none; d=google.com; s=arc-20160816; b=WPEJewcFfOrwW/RLEB9EIb8CB81jep2CBMHts44IfDobECjtfXBfEYQ8fJohswbTMz y3Ww+wSNVzJvrLI99qbghW+4GK/8QbCnc44WNvZhDgtyUtGlEN5syQkZFuHbsX4/thJA fa4uZeged2rYTDDaGGhIV2lH/MBKpdaRH63yJro5erln+2gzyiSoOrYLIOn0dSuLel2W 7F5ANMknI1deeLaPQinWLzxx5cCC77SHPwShz+BMgigfXNLfBdIvLg3bL9VVHRjQdrME tVDMXiiSZ5Ohu4Ova2dEcYL7GT6UnYH5bLEtDeLlfel1czPAs6kit9FU2bH4ysgBd4Rw nxbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from; bh=s8CC92PVpJyvRDbrGa+LlfzYmW5gvHvx92d60fU/Vn0=; b=ZbQSB48q40u9KvC1Li46zLjkNIdlvsoQpuIv8fBw3MF05eXJi1xE8GPE/z+OuLRp0o P1EWFh7FPHBLtqlgS1fsBi8wjsxYhowtyjHmszb7XrQfsLuL+PS0sUnQlSdF8O6e7/zG FBGw1p1RzWyOknQtZ9i+UWDaG+V02RKsZVDA8GtdGwB8HR4gnACe/pZuPNBWqXRq3Vrh ELR1fg2Cw/TAtC5qSuuhtKoQhc3l40N5lPDMGiE5kM0hPpWTIhPatyCILXnXN+G5RO1e 3MEX7kPpXids8MeBR+4q5ieVIOiYKnZRA2qYBoSubnmuAE09HMDSykUvN227w4aLuM5E oP/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id o18si13484589ejc.142.2019.07.17.09.24.12; Wed, 17 Jul 2019 09:24:12 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0146C1BE6A; Wed, 17 Jul 2019 18:24:06 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 0F2CD1B9AF for ; Wed, 17 Jul 2019 18:24:01 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 8224A1A01F8; Wed, 17 Jul 2019 18:24:01 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id CD0E11A00C9; Wed, 17 Jul 2019 18:23:59 +0200 (CEST) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 464BA402D5; Thu, 18 Jul 2019 00:23:57 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org, akhil.goyal@nxp.com Date: Wed, 17 Jul 2019 21:52:42 +0530 Message-Id: <20190717162242.19689-2-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190717162242.19689-1-hemant.agrawal@nxp.com> References: <20190717162242.19689-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH 2/2] crypto/dpaa2_sec: fix err handling for session init failures 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" The session init shall return failure if the internal session create fails for any reasons. Fixes: 13273250eec5 ("crypto/dpaa2_sec: support AES-GCM and CTR") Cc: stable@dpdk.org Signed-off-by: Hemant Agrawal --- drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c index 0d273bb62..26458e5d1 100644 --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c @@ -2165,6 +2165,7 @@ dpaa2_sec_set_session_parameters(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, void *sess) { dpaa2_sec_session *session = sess; + int ret; PMD_INIT_FUNC_TRACE(); @@ -2180,37 +2181,37 @@ dpaa2_sec_set_session_parameters(struct rte_cryptodev *dev, /* Cipher Only */ if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER && xform->next == NULL) { session->ctxt_type = DPAA2_SEC_CIPHER; - dpaa2_sec_cipher_init(dev, xform, session); + ret = dpaa2_sec_cipher_init(dev, xform, session); /* Authentication Only */ } else if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH && xform->next == NULL) { session->ctxt_type = DPAA2_SEC_AUTH; - dpaa2_sec_auth_init(dev, xform, session); + ret = dpaa2_sec_auth_init(dev, xform, session); /* Cipher then Authenticate */ } else if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER && xform->next->type == RTE_CRYPTO_SYM_XFORM_AUTH) { session->ext_params.aead_ctxt.auth_cipher_text = true; - dpaa2_sec_aead_chain_init(dev, xform, session); + ret = dpaa2_sec_aead_chain_init(dev, xform, session); /* Authenticate then Cipher */ } else if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH && xform->next->type == RTE_CRYPTO_SYM_XFORM_CIPHER) { session->ext_params.aead_ctxt.auth_cipher_text = false; - dpaa2_sec_aead_chain_init(dev, xform, session); + ret = dpaa2_sec_aead_chain_init(dev, xform, session); /* AEAD operation for AES-GCM kind of Algorithms */ } else if (xform->type == RTE_CRYPTO_SYM_XFORM_AEAD && xform->next == NULL) { - dpaa2_sec_aead_init(dev, xform, session); + ret = dpaa2_sec_aead_init(dev, xform, session); } else { DPAA2_SEC_ERR("Invalid crypto type"); return -EINVAL; } - return 0; + return ret; } static int