]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
crypto: caam - Pad SG length when allocating hash edesc
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 12 Sep 2024 09:57:13 +0000 (17:57 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 21 Sep 2024 09:14:59 +0000 (17:14 +0800)
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>
drivers/crypto/caam/caamhash.c

index fdd724228c2fa8accc7c7ebc1244c5ee92423247..25c02e2672585830a339aee391b1cf59d76d1db6 100644 (file)
@@ -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;