From f552a455695ef657ad168ad9617064e5d3a1fe34 Mon Sep 17 00:00:00 2001 From: Nagaraj P N Date: Thu, 20 Feb 2025 13:59:09 +0530 Subject: [PATCH] cryptodev: update buf addr check for SHA requests Input buffer VA needs to be checked only for non-zero copy IVC queues. Bug 4999798 Change-Id: Ic8bcc44abb65f8e2d614f6734870e81a8d5ec03c Signed-off-by: Nagaraj P N Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3306711 Reviewed-by: Leo Chiu GVS: buildbot_gerritrpt Reviewed-by: svcacv Reviewed-by: Sandeep Trasi --- drivers/crypto/tegra-nvvse-cryptodev.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/crypto/tegra-nvvse-cryptodev.c b/drivers/crypto/tegra-nvvse-cryptodev.c index f2118124..6df9aae3 100644 --- a/drivers/crypto/tegra-nvvse-cryptodev.c +++ b/drivers/crypto/tegra-nvvse-cryptodev.c @@ -227,19 +227,10 @@ static int tnvvse_crypto_validate_sha_update_req(struct tnvvse_crypto_ctx *ctx, goto exit; } - if (sha_update_ctl->input_buffer_size == 0U) { - if (sha_update_ctl->is_last == 0U) { - pr_err("%s(): zero length non-last request is not supported\n", __func__); - ret = -EINVAL; - goto exit; - } - } else { - if (sha_update_ctl->in_buff == NULL) { - pr_err("%s(): input buffer address is NULL for non-zero len req\n", - __func__); - ret = -EINVAL; - goto exit; - } + if ((sha_update_ctl->input_buffer_size == 0U) && (sha_update_ctl->is_last == 0U)) { + pr_err("%s(): zero length non-last request is not supported\n", __func__); + ret = -EINVAL; + goto exit; } if (ctx->is_zero_copy_node) { @@ -273,6 +264,13 @@ static int tnvvse_crypto_validate_sha_update_req(struct tnvvse_crypto_ctx *ctx, goto exit; } + if ((sha_update_ctl->input_buffer_size > 0U) && (sha_update_ctl->in_buff == NULL)) { + pr_err("%s(): input buffer address is NULL for non-zero len req\n", + __func__); + ret = -EINVAL; + goto exit; + } + if (sha_update_ctl->input_buffer_size > ivc_database.max_buffer_size[ctx->node_id]) { pr_err("%s(): Msg size is greater than supported size of %d Bytes\n",