From patchwork Mon Nov 13 08:01:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Karas X-Patchwork-Id: 134130 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 6A85943319; Mon, 13 Nov 2023 09:04:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B14D140633; Mon, 13 Nov 2023 09:04:27 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 9EB9940279; Mon, 13 Nov 2023 09:04:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699862667; x=1731398667; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=6oClffUVeoVs+Drhq61kI+zlsVwyhq+ovMrHEI4nWzM=; b=HsOI8irp+88MI3N9/LWsevNCIG46nL/CheCOU6ueMAkpBDHd29KEdtBg NuiTpbo8C6jD6UcaddGqYaK1Bnq5E4+sAp4FhSmO00LQmjsCJTARSdbw7 tk13iD8H54V5WsGKtcvNrJkZShANmjR7LtwupScElXEnZJJfKSsHBzGUE YwXf9ZWNQnuIn4Ijf4tTSysMyTggBp60VYkdiHufoQs9Hf/3OSmLNcDJ3 q0WpFcaTEA8NMGBhiqQRW3bEKC8m0sQJRX0AaZ4F9ObRs6U4OV3rXVp6N daX1x52TTvFSrSeKcYxNReZ6ldR0Yb2RZAHKyS/teGOtqs8+m+mBXENJQ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10892"; a="389260301" X-IronPort-AV: E=Sophos;i="6.03,298,1694761200"; d="scan'208";a="389260301" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2023 00:04:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10892"; a="799125448" X-IronPort-AV: E=Sophos;i="6.03,298,1694761200"; d="scan'208";a="799125448" Received: from unknown (HELO fedora38.localdomain) ([10.211.11.138]) by orsmga001.jf.intel.com with ESMTP; 13 Nov 2023 00:04:22 -0800 From: Krzysztof Karas To: Kai Ji , Pablo de Lara , Marcel Cornu , Ciara Power Cc: dev@dpdk.org, Krzysztof Karas , stable@dpdk.org Subject: [PATCH v2] crypto/ipsec_mb: do not dequeue ops after flush Date: Mon, 13 Nov 2023 08:01:57 +0000 Message-ID: <20231113080158.3872440-1-krzysztof.karas@intel.com> X-Mailer: git-send-email 2.41.0 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 Previously it was possible to increment `processed_jobs` to a value greater than requested `nb_ops`, because after flushing at most `nb_ops` jobs the while loop continued, so `processed_jobs` could still be incremented and it was possible for this variable to be greater than `nb_ops`. If `ops` provided to the function were only `nb_ops` long, then the `aesni_mb_dequeue_burst()` would write to the memory outside of `ops` array. Fixes: b50b8b5b38f8 ("crypto/ipsec_mb: use burst API in AESNI") Cc: stable@dpdk.org Signed-off-by: Krzysztof Karas Acked-by: Ciara Power Acked-by: Marcel Cornu Acked-by: Pablo de Lara --- v2: * Shortened title to fit in the limit. * Changed nb_ops decrementing from 'nb_jobs' to 'i'. drivers/crypto/ipsec_mb/pmd_aesni_mb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/ipsec_mb/pmd_aesni_mb.c b/drivers/crypto/ipsec_mb/pmd_aesni_mb.c index 9e298023d7..aa08490e0c 100644 --- a/drivers/crypto/ipsec_mb/pmd_aesni_mb.c +++ b/drivers/crypto/ipsec_mb/pmd_aesni_mb.c @@ -2056,7 +2056,7 @@ aesni_mb_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops, uint16_t n = (nb_ops / burst_sz) ? burst_sz : nb_ops; - while (unlikely((IMB_GET_NEXT_BURST(mb_mgr, n, jobs)) < n)) { + if (unlikely((IMB_GET_NEXT_BURST(mb_mgr, n, jobs)) < n)) { /* * Not enough free jobs in the queue * Flush n jobs until enough jobs available @@ -2074,6 +2074,8 @@ aesni_mb_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops, break; } } + nb_ops -= i; + continue; } /*