Commit 35336216 authored by William Clark's avatar William Clark Committed by Nikola Majkić
Browse files

crypto: msm: check potential integer overflow


According to the specification of AEAD, AEAD request crypt length is
not a fixed maximum and associated length is also same. This could
lead to potential integer overflow, thus allocating less memory. So
we need to check potential integer overflow on AEAD request length.

CRs-Fixed: 726872
Change-Id: Ie7708000bfd8c57e2fba8e02230a7ce9cdc9634c
Signed-off-by: default avatarWilliam Clark <wclark@codeaurora.org>
parent 5d6e9b74
......@@ -1424,12 +1424,12 @@ static int _qcrypto_process_aead(struct crypto_priv *cp,
rctx->orig_src = req->src;
rctx->orig_dst = req->dst;
if ((MAX_ALIGN_SIZE*2 > ULONG_MAX - req->assoclen) ||
((MAX_ALIGN_SIZE*2 + req->assoclen) >
ULONG_MAX - qreq.authsize) ||
((MAX_ALIGN_SIZE*2 + req->assoclen +
if ((MAX_ALIGN_SIZE*2 > UINT_MAX - qreq.assoclen) ||
((MAX_ALIGN_SIZE*2 + qreq.assoclen) >
UINT_MAX - qreq.authsize) ||
((MAX_ALIGN_SIZE*2 + qreq.assoclen +
qreq.authsize) >
ULONG_MAX - req->cryptlen)) {
UINT_MAX - req->cryptlen)) {
pr_err("Integer overflow on aead req length.\n");
return -EINVAL;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment