[v1] eventdev/crypto: overflow in circular buffer

Message ID 20221130154258.1694578-1-ganapati.kundapura@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers
Series [v1] eventdev/crypto: overflow in circular buffer |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-abi-testing warning Testing issues
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS

Commit Message

Ganapati Kundapura Nov. 30, 2022, 3:42 p.m. UTC
  Crypto adapter checks CPM backpressure once in enq_run()
This leads to buffer overflow if some ops failed to flush
to cryptodev.

Checked CPM backpressure for every iteration in enq_run()

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
  

Patch

diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
index 3c585d7..e7e9455 100644
--- a/lib/eventdev/rte_event_crypto_adapter.c
+++ b/lib/eventdev/rte_event_crypto_adapter.c
@@ -585,14 +585,15 @@  eca_crypto_adapter_enq_run(struct event_crypto_adapter *adapter,
 	if (adapter->mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW)
 		return 0;
 
-	if (unlikely(adapter->stop_enq_to_cryptodev)) {
-		nb_enqueued += eca_crypto_enq_flush(adapter);
+	for (nb_enq = 0; nb_enq < max_enq; nb_enq += n) {
 
-		if (unlikely(adapter->stop_enq_to_cryptodev))
-			goto skip_event_dequeue_burst;
-	}
+		if (unlikely(adapter->stop_enq_to_cryptodev)) {
+			nb_enqueued += eca_crypto_enq_flush(adapter);
+
+			if (unlikely(adapter->stop_enq_to_cryptodev))
+				break;
+		}
 
-	for (nb_enq = 0; nb_enq < max_enq; nb_enq += n) {
 		stats->event_poll_count++;
 		n = rte_event_dequeue_burst(event_dev_id,
 					    event_port_id, ev, BATCH_SIZE, 0);
@@ -603,8 +604,6 @@  eca_crypto_adapter_enq_run(struct event_crypto_adapter *adapter,
 		nb_enqueued += eca_enq_to_cryptodev(adapter, ev, n);
 	}
 
-skip_event_dequeue_burst:
-
 	if ((++adapter->transmit_loop_count &
 		(CRYPTO_ENQ_FLUSH_THRESHOLD - 1)) == 0) {
 		nb_enqueued += eca_crypto_enq_flush(adapter);