Re: [PATCH 4.19 046/105] crypto: ccree - dont map MAC key on stack

From: Pavel Machek
Date: Wed May 22 2019 - 04:52:40 EST


Hi!

> The MAC hash key might be passed to us on stack. Copy it to
> a slab buffer before mapping to gurantee proper DMA mapping.
>
> Signed-off-by: Gilad Ben-Yossef <gilad@xxxxxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx # v4.19+
> Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
>
> ---
> drivers/crypto/ccree/cc_hash.c | 24 +++++++++++++++++++++---
> 1 file changed, 21 insertions(+), 3 deletions(-)
>
> --- a/drivers/crypto/ccree/cc_hash.c
> +++ b/drivers/crypto/ccree/cc_hash.c
> @@ -64,6 +64,7 @@ struct cc_hash_alg {
> struct hash_key_req_ctx {
> u32 keylen;
> dma_addr_t key_dma_addr;
> + u8 *key;
> };
>
> /* hash per-session context */

AFAICT, key is used just as a local variable in cc_hash_setkey() and
cc_xcbc_setkey() functions. Could we make it local variable to save a
bit of memory (and make code less confusing)?

Thanks,
Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Attachment: signature.asc
Description: Digital signature