From b812567ef6daa2a99a05a38bd79252c97e46078b Mon Sep 17 00:00:00 2001 From: Abhinandan Gujjar Date: Sun, 18 Jul 2021 17:48:51 +0530 Subject: [PATCH] test/crypto: fix mempool size for session-less 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: 3c2c535ecfc0 ("test: add event crypto adapter auto-test") Cc: stable@dpdk.org Signed-off-by: Abhinandan Gujjar Reported-by: Ciara Power Acked-by: Akhil Goyal --- app/test/test_event_crypto_adapter.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/test/test_event_crypto_adapter.c b/app/test/test_event_crypto_adapter.c index f689bc1f22..3ad20921e2 100644 --- a/app/test/test_event_crypto_adapter.c +++ b/app/test/test_event_crypto_adapter.c @@ -228,8 +228,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, @@ -423,8 +422,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, @@ -520,7 +518,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"); -- 2.20.1