summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2024-09-12 11:57:13 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2024-09-21 11:14:59 +0200
commit5124bc96162667766f6120b19f57a640c2eccb2a (patch)
treed96f475455e029c9d636af6c379f294b5748aad1
parentcrypto: n2 - Set err to EINVAL if snprintf fails for hmac (diff)
downloadlinux-5124bc96162667766f6120b19f57a640c2eccb2a.tar.xz
linux-5124bc96162667766f6120b19f57a640c2eccb2a.zip
crypto: caam - Pad SG length when allocating hash edesc
Because hardware will read in multiples of 4 SG entries, ensure the allocated length is always padded. This was already done by some callers of ahash_edesc_alloc, but ahash_digest was conspicuously missing. In any case, doing it in the allocation function ensures that the memory is always there. Reported-by: Guangwu Zhang <guazhang@redhat.com> Fixes: a5e5c13398f3 ("crypto: caam - fix S/G table passing page boundary") Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/crypto/caam/caamhash.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index fdd724228c2f..25c02e267258 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -708,6 +708,7 @@ static struct ahash_edesc *ahash_edesc_alloc(struct ahash_request *req,
GFP_KERNEL : GFP_ATOMIC;
struct ahash_edesc *edesc;
+ sg_num = pad_sg_nents(sg_num);
edesc = kzalloc(struct_size(edesc, sec4_sg, sg_num), flags);
if (!edesc)
return NULL;