Skip to content

Commit

Permalink
test/crypto: fix mempool size for session-less
Browse files Browse the repository at this point in the history
[ upstream commit b812567 ]

Currently, private_data_offset for the sessionless is computed
wrongly which includes extra bytes added by
sizeof(struct rte_crypto_sym_xform) * 2. This causes buffer
overflow which leads to test application crash while freeing the
ops mempool. This patch provides fix for the same and also takes
care of increasing the length of ops to accommodate space for
rte_event_crypto_metadata while creating the crypto ops mempool.

Fixes: 3c2c535 ("test: add event crypto adapter auto-test")

Signed-off-by: Abhinandan Gujjar <abhinandan.gujjar@intel.com>
Reported-by: Ciara Power <ciara.power@intel.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
  • Loading branch information
asgujjar authored and bluca committed Jul 26, 2021
1 parent 89d903b commit db87874
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/test/test_event_crypto_adapter.c
Expand Up @@ -224,8 +224,7 @@ test_op_forward_mode(uint8_t session_less)
op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
first_xform = &cipher_xform;
sym_op->xform = first_xform;
uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH +
(sizeof(struct rte_crypto_sym_xform) * 2);
uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH;
op->private_data_offset = len;
/* Fill in private data information */
rte_memcpy(&m_data.response_info, &response_info,
Expand Down Expand Up @@ -419,8 +418,7 @@ test_op_new_mode(uint8_t session_less)
op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
first_xform = &cipher_xform;
sym_op->xform = first_xform;
uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH +
(sizeof(struct rte_crypto_sym_xform) * 2);
uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH;
op->private_data_offset = len;
/* Fill in private data information */
rte_memcpy(&m_data.response_info, &response_info,
Expand Down Expand Up @@ -516,7 +514,8 @@ configure_cryptodev(void)
NUM_MBUFS, MBUF_CACHE_SIZE,
DEFAULT_NUM_XFORMS *
sizeof(struct rte_crypto_sym_xform) +
MAXIMUM_IV_LENGTH,
MAXIMUM_IV_LENGTH +
sizeof(union rte_event_crypto_metadata),
rte_socket_id());
if (params.op_mpool == NULL) {
RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
Expand Down

0 comments on commit db87874

Please sign in to comment.