Skip to content

Commit 9714061

Browse files
gcabidduherbertx
authored andcommitted
crypto: qat - add param check for RSA
Reject requests with a source buffer that is bigger than the size of the key. This is to prevent a possible integer underflow that might happen when copying the source scatterlist into a linear buffer. Cc: stable@vger.kernel.org Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Reviewed-by: Adam Guerin <adam.guerin@intel.com> Reviewed-by: Wojciech Ziemba <wojciech.ziemba@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 029aa46 commit 9714061

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/crypto/qat/qat_common/qat_asym_algs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,10 @@ static int qat_rsa_enc(struct akcipher_request *req)
656656
req->dst_len = ctx->key_sz;
657657
return -EOVERFLOW;
658658
}
659+
660+
if (req->src_len > ctx->key_sz)
661+
return -EINVAL;
662+
659663
memset(msg, '\0', sizeof(*msg));
660664
ICP_QAT_FW_PKE_HDR_VALID_FLAG_SET(msg->pke_hdr,
661665
ICP_QAT_FW_COMN_REQ_FLAG_SET);
@@ -785,6 +789,10 @@ static int qat_rsa_dec(struct akcipher_request *req)
785789
req->dst_len = ctx->key_sz;
786790
return -EOVERFLOW;
787791
}
792+
793+
if (req->src_len > ctx->key_sz)
794+
return -EINVAL;
795+
788796
memset(msg, '\0', sizeof(*msg));
789797
ICP_QAT_FW_PKE_HDR_VALID_FLAG_SET(msg->pke_hdr,
790798
ICP_QAT_FW_COMN_REQ_FLAG_SET);

0 commit comments

Comments
 (0)