summaryrefslogtreecommitdiffstats
path: root/drivers/crypto/qat
diff options
context:
space:
mode:
authorShant KumarX Sonnad <shant.kumarx.sonnad@intel.com>2019-04-29 17:43:16 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2019-05-23 08:01:02 +0200
commitc044b62c3679fb2814fd4684fd8bb51ba38d6f3c (patch)
treed6f03cf8b7f22486fec46785927d1d754235621b /drivers/crypto/qat
parentcrypto: qat - remove spin_lock in qat_ablkcipher_setkey (diff)
downloadlinux-c044b62c3679fb2814fd4684fd8bb51ba38d6f3c.tar.xz
linux-c044b62c3679fb2814fd4684fd8bb51ba38d6f3c.zip
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 <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>
Diffstat (limited to 'drivers/crypto/qat')
-rw-r--r--drivers/crypto/qat/qat_common/qat_algs.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c
index 413e05e8891e..b60156d987eb 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;