Skip to content

Commit

Permalink
eventdev/crypto: fix enqueueing
Browse files Browse the repository at this point in the history
[ upstream commit f5d48ed52da03d5d3b68889e844bab59b2ffb4f0 ]

When tail pointer of circular buffer rolls over as the circular buffer
becomes full, crypto adapter is enqueueing ops beyond the size of the
circular buffer leading to segfault due to invalid ops access.

Fixed by enqueueing ops from head pointer to (size-head) number of ops
when circular 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 <ganapati.kundapura@intel.com>
Acked-by: Abhinandan Gujjar <abhinandan.gujjar@intel.com>
  • Loading branch information
gkundap authored and bluca committed Mar 13, 2024
1 parent 7a45bfb commit 85bd236
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/eventdev/rte_event_crypto_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,20 +237,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;
}
}

Expand Down

0 comments on commit 85bd236

Please sign in to comment.