]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
crypto: qat - add check for negative offset in alg precompute function
authorShant KumarX Sonnad <shant.kumarx.sonnad@intel.com>
Mon, 29 Apr 2019 15:43:16 +0000 (16:43 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 23 May 2019 06:01:02 +0000 (14:01 +0800)
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 <conor.mcloughlin@intel.com>
Tested-by: Sergey Portnoy <sergey.portnoy@intel.com>
Signed-off-by: Shant KumarX Sonnad <shant.kumarx.sonnad@intel.com>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/qat/qat_common/qat_algs.c

index 413e05e8891e0cf313686e99f7ce14a2db4edb75..b60156d987eb3bad4c4df5cc675a5f5d30bd2a33 100644 (file)
@@ -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;