crypto/qat: fix process type handling

This patch fix the memory corruptions issue reported by
coverity. The process type handling in QAT PMDs where only
primary and secondary process are supported in qat build
request.

Coverity issue: 376551, 376570, 376534
Fixes: fb3b9f492205 ("crypto/qat: rework burst data path")

Signed-off-by: Kai Ji <kai.ji@intel.com>
This commit is contained in:
Kai Ji 2022-03-01 23:02:54 +08:00 committed by Akhil Goyal
parent 8545c6d2e2
commit 1df045712d
4 changed files with 13 additions and 4 deletions

View File

@ -358,6 +358,9 @@ qat_sym_crypto_set_session_gen3(void *cdev __rte_unused, void *session)
enum rte_proc_type_t proc_type = rte_eal_process_type();
int ret;
if (proc_type == RTE_PROC_AUTO || proc_type == RTE_PROC_INVALID)
return -EINVAL;
ret = qat_sym_crypto_set_session_gen1(cdev, session);
/* special single pass build request for GEN3 */
if (ctx->is_single_pass)

View File

@ -189,6 +189,9 @@ qat_sym_crypto_set_session_gen4(void *cdev, void *session)
enum rte_proc_type_t proc_type = rte_eal_process_type();
int ret;
if (proc_type == RTE_PROC_AUTO || proc_type == RTE_PROC_INVALID)
return -EINVAL;
ret = qat_sym_crypto_set_session_gen1(cdev, session);
/* special single pass build request for GEN4 */
if (ctx->is_single_pass && ctx->is_ucs)

View File

@ -1149,6 +1149,9 @@ qat_sym_crypto_set_session_gen1(void *cryptodev __rte_unused, void *session)
enum rte_proc_type_t proc_type = rte_eal_process_type();
int handle_mixed = 0;
if (proc_type == RTE_PROC_AUTO || proc_type == RTE_PROC_INVALID)
return -EINVAL;
if ((ctx->qat_cmd == ICP_QAT_FW_LA_CMD_HASH_CIPHER ||
ctx->qat_cmd == ICP_QAT_FW_LA_CMD_CIPHER_HASH) &&
!ctx->is_gmac) {

View File

@ -60,6 +60,10 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
uintptr_t build_request_p = (uintptr_t)opaque[1];
qat_sym_build_request_t build_request = (void *)build_request_p;
struct qat_sym_session *ctx = NULL;
enum rte_proc_type_t proc_type = rte_eal_process_type();
if (proc_type == RTE_PROC_AUTO || proc_type == RTE_PROC_INVALID)
return -EINVAL;
if (likely(op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)) {
ctx = get_sym_session_private_data(op->sym->session,
@ -71,11 +75,9 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
if (sess != (uintptr_t)ctx) {
struct rte_cryptodev *cdev;
struct qat_cryptodev_private *internals;
enum rte_proc_type_t proc_type;
cdev = rte_cryptodev_pmd_get_dev(ctx->dev_id);
internals = cdev->data->dev_private;
proc_type = rte_eal_process_type();
if (internals->qat_dev->qat_dev_gen != dev_gen) {
op->status =
@ -105,7 +107,6 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
if ((void *)sess != (void *)op->sym->sec_session) {
struct rte_cryptodev *cdev;
struct qat_cryptodev_private *internals;
enum rte_proc_type_t proc_type;
ctx = get_sec_session_private_data(
op->sym->sec_session);
@ -130,7 +131,6 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
}
cdev = rte_cryptodev_pmd_get_dev(ctx->dev_id);
internals = cdev->data->dev_private;
proc_type = rte_eal_process_type();
if (internals->qat_dev->qat_dev_gen != dev_gen) {
op->status =