From patchwork Sun Jul 18 12:18:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gujjar, Abhinandan S" X-Patchwork-Id: 96014 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B5062A0C47; Sun, 18 Jul 2021 14:20:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6B1BE40687; Sun, 18 Jul 2021 14:20:53 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 6611440683 for ; Sun, 18 Jul 2021 14:20:52 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10048"; a="191224566" X-IronPort-AV: E=Sophos;i="5.84,249,1620716400"; d="scan'208";a="191224566" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2021 05:20:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,249,1620716400"; d="scan'208";a="563743085" Received: from unknown (HELO localhost.localdomain) ([10.190.210.97]) by orsmga004.jf.intel.com with ESMTP; 18 Jul 2021 05:20:48 -0700 From: Abhinandan Gujjar To: dev@dpdk.org, gakhil@marvell.com, jerinj@marvell.com Cc: abhinandan.gujjar@intel.com, ciara.power@intel.com Date: Sun, 18 Jul 2021 17:48:51 +0530 Message-Id: <20210718121851.176359-1-abhinandan.gujjar@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [dpdk-dev] [v2] test: fix crypto_op length for sessionless case X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Currently, private_data_offset for the sessionless is computed wrongly which includes extra bytes added by sizeof(struct rte_crypto_sym_xform) * 2. This causes buffer overflow which leads to test application crash while freeing the ops mempool. This patch provides fix for the same and also takes care of increasing the length of ops to accommodate space for rte_event_crypto_metadata while creating the crypto ops mempool. Fixes: 3c2c535ecfc0 ("test: add event crypto adapter auto-test") Reported-by: ciara.power@intel.com Signed-off-by: Abhinandan Gujjar Acked-by: Akhil Goyal --- v2: - Fix length calculation for copying metadata - Update mempool's size to accommodate space for metadata app/test/test_event_crypto_adapter.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c index f689bc1f2..3ad20921e 100644 --- a/app/test/test_event_crypto_adapter.c +++ b/app/test/test_event_crypto_adapter.c @@ -228,8 +228,7 @@ test_op_forward_mode(uint8_t session_less) op->sess_type = RTE_CRYPTO_OP_SESSIONLESS; first_xform = &cipher_xform; sym_op->xform = first_xform; - uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH + - (sizeof(struct rte_crypto_sym_xform) * 2); + uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH; op->private_data_offset = len; /* Fill in private data information */ rte_memcpy(&m_data.response_info, &response_info, @@ -423,8 +422,7 @@ test_op_new_mode(uint8_t session_less) op->sess_type = RTE_CRYPTO_OP_SESSIONLESS; first_xform = &cipher_xform; sym_op->xform = first_xform; - uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH + - (sizeof(struct rte_crypto_sym_xform) * 2); + uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH; op->private_data_offset = len; /* Fill in private data information */ rte_memcpy(&m_data.response_info, &response_info, @@ -520,7 +518,8 @@ configure_cryptodev(void) NUM_MBUFS, MBUF_CACHE_SIZE, DEFAULT_NUM_XFORMS * sizeof(struct rte_crypto_sym_xform) + - MAXIMUM_IV_LENGTH, + MAXIMUM_IV_LENGTH + + sizeof(union rte_event_crypto_metadata), rte_socket_id()); if (params.op_mpool == NULL) { RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");