From: Shant KumarX Sonnad Date: Mon, 29 Apr 2019 15:43:16 +0000 (+0100) Subject: crypto: qat - add check for negative offset in alg precompute function X-Git-Tag: v5.3-rc1~184^2~142 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c044b62c3679fb2814fd4684fd8bb51ba38d6f3c;p=thirdparty%2Fkernel%2Flinux.git crypto: qat - add check for negative offset in alg precompute function The offset is calculated based on type of hash algorithum. If the algorithum is invalid the offset can have negative value. Hence added negative offset check and return -EFAULT. Reviewed-by: Conor Mcloughlin Tested-by: Sergey Portnoy Signed-off-by: Shant KumarX Sonnad Signed-off-by: Giovanni Cabiddu Signed-off-by: Herbert Xu --- diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c index 413e05e8891e0..b60156d987eb3 100644 --- a/drivers/crypto/qat/qat_common/qat_algs.c +++ b/drivers/crypto/qat/qat_common/qat_algs.c @@ -222,6 +222,9 @@ static int qat_alg_do_precomputes(struct icp_qat_hw_auth_algo_blk *hash, return -EFAULT; offset = round_up(qat_get_inter_state_size(ctx->qat_hash_alg), 8); + if (offset < 0) + return -EFAULT; + hash_state_out = (__be32 *)(hash->sha.state1 + offset); hash512_state_out = (__be64 *)hash_state_out;