From patchwork Wed Jun 29 16:10:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rebecca Troy X-Patchwork-Id: 113562 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 6DFADA054F; Wed, 29 Jun 2022 18:13:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4ED3B400D7; Wed, 29 Jun 2022 18:13:04 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 986B540042; Wed, 29 Jun 2022 18:12:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656519182; x=1688055182; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sXJjlHkpKWFknMn6bUJMF+DsFkXTaKVpC/OxsbpxLx8=; b=e6I/R/97UfnLX0ESrBehOkadNu2Fs9x6JaE7jsTPUzpNlBQT9wzUpw2V hMQGSpHkQizfUm//ayR+rLci57aNfl3QsZWw+Q60vrN9JMdQRoXypr/q0 NrEKrAEQ8y6g0nbGA97a5ofmHeWFKmL7YS3uWAeVw3KHg3lV57WpibxYu 5i9Zdb5m76ELAaTcUjRgz0uOqZTECI0R3IMklKK6JzgW7kg7gLC4TH0LX dNtYUdG1kvWy533F7G1dQLeOTPeG66XnZ+VOMM+/xES/iddps+azPwH2w hKhzR6wY9CoJgXHKZ3vJ//gDJGRho93SDi+InVk0RkZ1t50ZfaO6XPQQb Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10393"; a="282807149" X-IronPort-AV: E=Sophos;i="5.92,231,1650956400"; d="scan'208";a="282807149" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2022 09:10:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,231,1650956400"; d="scan'208";a="680566484" Received: from silpixa00401279.ir.intel.com (HELO silpixa00401279.ger.corp.intel.com) ([10.237.222.42]) by FMSMGA003.fm.intel.com with ESMTP; 29 Jun 2022 09:10:39 -0700 From: Rebecca Troy To: Fan Zhang Cc: dev@dpdk.org, Rebecca Troy , fiona.trahe@intel.com, stable@dpdk.org Subject: [PATCH v2] crypto/qat: fix docsis segmentation fault Date: Wed, 29 Jun 2022 16:10:36 +0000 Message-Id: <20220629161037.94805-1-rebecca.troy@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220627164352.181868-1-rebecca.troy@intel.com> References: <20220627164352.181868-1-rebecca.troy@intel.com> MIME-Version: 1.0 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 Currently if AES or DES algorithms fail for Docsis test suite, a segmentation fault occurs when cryptodev_qat_autotest is ran. This is due to a duplicate call of EVP_CIPHER_CTX_free for the session context. Ctx is freed firstly in the bpi_cipher_ctx_init function and then again at the end of qat_sym_session_configure_cipher function. This commit fixes this bug by removing the first instance of EVP_CIPHER_CTX_free, leaving just the dedicated function in the upper level to free the ctx. Fixes: 98f0608 ("crypto/qat: add symmetric session file") Cc: fiona.trahe@intel.com Cc: stable@dpdk.org Signed-off-by: Rebecca Troy Acked-by: Fan Zhang --- V2: - Changed the bug fix to set *ctx to NULL after the first instance of EVP_CIPHER_CTX_free, rather than removing it. This will ensure NULL checks are met appropriately in further EVP_CIPHER_CTX_free calls, avoiding segmentation fault without relying solely on the caller to free the *ctx. . --- drivers/crypto/qat/qat_sym_session.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c index e40c042ba9..b30396487e 100644 --- a/drivers/crypto/qat/qat_sym_session.c +++ b/drivers/crypto/qat/qat_sym_session.c @@ -136,8 +136,10 @@ bpi_cipher_ctx_init(enum rte_crypto_cipher_algorithm cryptodev_algo, return 0; ctx_init_err: - if (*ctx != NULL) + if (*ctx != NULL) { EVP_CIPHER_CTX_free(*ctx); + *ctx = NULL; + } return ret; }