From patchwork Fri Feb 24 15:26:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Kulasek X-Patchwork-Id: 20729 X-Patchwork-Delegate: pablo.de.lara.guarch@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id F35B02B88; Fri, 24 Feb 2017 16:26:14 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 4ED3C2A5E for ; Fri, 24 Feb 2017 16:26:12 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP; 24 Feb 2017 07:26:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,201,1484035200"; d="scan'208";a="52359359" Received: from unknown (HELO Sent) ([10.103.102.151]) by orsmga002.jf.intel.com with SMTP; 24 Feb 2017 07:26:10 -0800 Received: by Sent (sSMTP sendmail emulation); Fri, 24 Feb 2017 16:26:09 +0100 From: Tomasz Kulasek To: dev@dpdk.org Cc: pablo.de.lara.guarch@intel.com Date: Fri, 24 Feb 2017 16:26:00 +0100 Message-Id: <1487949960-22048-1-git-send-email-tomaszx.kulasek@intel.com> X-Mailer: git-send-email 2.1.4 Subject: [dpdk-dev] [PATCH] app/crypto-perf: fix uninitialized values for null operations 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" Some values are uninitialized for "cipher null" and "auth null" operations. It may cause unpredictable results for some crypto pmd drivers, or even segmentation fault. This patch sets values for null operations to zero. Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test application") Signed-off-by: Tomasz Kulasek Acked-by: Pablo de Lara --- app/test-crypto-perf/cperf_ops.c | 16 ++++++++++++++++ app/test-crypto-perf/cperf_test_vectors.c | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c index b8c0398..1795a37 100644 --- a/app/test-crypto-perf/cperf_ops.c +++ b/app/test-crypto-perf/cperf_ops.c @@ -333,6 +333,9 @@ test_vector->cipher_key.data; cipher_xform.cipher.key.length = test_vector->cipher_key.length; + } else { + cipher_xform.cipher.key.data = NULL; + cipher_xform.cipher.key.length = 0; } /* create crypto session */ sess = rte_cryptodev_sym_session_create(dev_id, &cipher_xform); @@ -354,6 +357,11 @@ auth_xform.auth.key.length = test_vector->auth_key.length; auth_xform.auth.key.data = test_vector->auth_key.data; + } else { + auth_xform.auth.digest_length = 0; + auth_xform.auth.add_auth_data_length = 0; + auth_xform.auth.key.length = 0; + auth_xform.auth.key.data = NULL; } /* create crypto session */ sess = rte_cryptodev_sym_session_create(dev_id, &auth_xform); @@ -378,6 +386,9 @@ test_vector->cipher_key.data; cipher_xform.cipher.key.length = test_vector->cipher_key.length; + } else { + cipher_xform.cipher.key.data = NULL; + cipher_xform.cipher.key.length = 0; } /* @@ -404,6 +415,11 @@ auth_xform.auth.key.data = test_vector->auth_key.data; } + } else { + auth_xform.auth.digest_length = 0; + auth_xform.auth.add_auth_data_length = 0; + auth_xform.auth.key.length = 0; + auth_xform.auth.key.data = NULL; } /* create crypto session for aes gcm */ diff --git a/app/test-crypto-perf/cperf_test_vectors.c b/app/test-crypto-perf/cperf_test_vectors.c index 6307f25..f7b3aa9 100644 --- a/app/test-crypto-perf/cperf_test_vectors.c +++ b/app/test-crypto-perf/cperf_test_vectors.c @@ -406,7 +406,7 @@ struct cperf_test_vector* options->op_type == CPERF_AUTH_THEN_CIPHER || options->op_type == CPERF_AEAD) { if (options->cipher_algo == RTE_CRYPTO_CIPHER_NULL) { - t_vec->cipher_key.length = -1; + t_vec->cipher_key.length = 0; t_vec->ciphertext.data = plaintext; t_vec->cipher_key.data = NULL; t_vec->iv.data = NULL;