From patchwork Wed Feb 28 10:39:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ganapati Kundapura X-Patchwork-Id: 137425 X-Patchwork-Delegate: jerinj@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 0E43A43C23; Wed, 28 Feb 2024 11:39:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EF85B42EFD; Wed, 28 Feb 2024 11:39:28 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by mails.dpdk.org (Postfix) with ESMTP id 559B94003C for ; Wed, 28 Feb 2024 11:39:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709116763; x=1740652763; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=mx7tWy4oDEp4DulhurjCSaJyf6H3ftcj/+vIX6naBVk=; b=jIqIJ3xQh9Y4uOGYbmQmMqvGRjaLUDq2CSpSV+KaxZe1syF0m9JjEQe6 U7E2pWZ9uUySM4OZ3m2LriHS72zyapHFWYUcoRs91/t60J76DWCahPHvH tIRfGKdfNCTFgvxeBpr79WzGkszRdIZzhabhbhDQUXaBg66lbO+xG5RyH 4leETjJ03MKrGOv8g28sKp5XXFCf4e8LcNHZRho/zIfnQdP2++9jbBNdj IXSEP1E0qrSYcYozkBwfBy1jmiO95F05Qgs7sCagQQDax620+BMDgwOyy xX5uVrM48azvL+8uzE/LKU/qMH2UJe/O6rJpsZVuCJL4twE/lfS7ghLqY g==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="3669729" X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="3669729" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 02:39:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,190,1705392000"; d="scan'208";a="12054647" Received: from txandevlnx322.an.intel.com ([10.123.117.44]) by orviesa004.jf.intel.com with ESMTP; 28 Feb 2024 02:39:22 -0800 From: Ganapati Kundapura To: dev@dpdk.org, jerinj@marvell.com, jay.jayatheerthan@intel.com Cc: s.v.naga.harish.k@intel.com, abhinandan.gujjar@intel.com Subject: [PATCH v1] eventdev/crypto: fix enqueueing invalid ops Date: Wed, 28 Feb 2024 04:39:19 -0600 Message-Id: <20240228103919.2018017-1-ganapati.kundapura@intel.com> X-Mailer: git-send-email 2.23.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 When tail pointer of Circ buffer rollsover as the Circ buffer becomes full, crypto adapter is enqueueing ops beyond the size of the Circ buffer leading to segfault due to invalid ops access. Fixed by enqueueing ops from head pointer to (size-head) number of ops when Circ buffer becomes full and the remaining ops will be flushed in next iteration. Fixes: 6c3c888656fc ("eventdev/crypto: fix circular buffer full case") Signed-off-by: Ganapati Kundapura Acked-by: Abhinandan Gujjar diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c index d46595d..9903f96 100644 --- a/lib/eventdev/rte_event_crypto_adapter.c +++ b/lib/eventdev/rte_event_crypto_adapter.c @@ -245,20 +245,28 @@ eca_circular_buffer_flush_to_cdev(struct crypto_ops_circular_buffer *bufp, struct rte_crypto_op **ops = bufp->op_buffer; if (*tailp > *headp) + /* Flush ops from head pointer to (tail - head) OPs */ n = *tailp - *headp; else if (*tailp < *headp) + /* Circ buffer - Rollover. + * Flush OPs from head to max size of buffer. + * Rest of the OPs will be flushed in next iteration. + */ n = bufp->size - *headp; else { /* head == tail case */ /* when head == tail, * circ buff is either full(tail pointer roll over) or empty */ if (bufp->count != 0) { - /* circ buffer is full */ - n = bufp->count; + /* Circ buffer - FULL. + * Flush OPs from head to max size of buffer. + * Rest of the OPS will be flushed in next iteration. + */ + n = bufp->size - *headp; } else { - /* circ buffer is empty */ + /* Circ buffer - Empty */ *nb_ops_flushed = 0; - return 0; /* buffer empty */ + return 0; } }