linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: Torsten Duwe <duwe@lst.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Russell King <linux@armlinux.org.uk>,
	linux-crypto@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, ardb@kernel.org
Subject: Re: [Patch][Fix] crypto: arm{,64} neon: memzero_explicit aes-cbc key
Date: Tue, 17 Mar 2020 22:17:43 +0000	[thread overview]
Message-ID: <20200317221743.GD20788@willie-the-truck> (raw)
In-Reply-To: <20200313110258.94A0668C4E@verein.lst.de>

[+Ard]

On Fri, Mar 13, 2020 at 12:02:58PM +0100, Torsten Duwe wrote:
> From: Torsten Duwe <duwe@suse.de>
> 
> At function exit, do not leave the expanded key in the rk struct
> which got allocated on the stack.
> 
> Signed-off-by: Torsten Duwe <duwe@suse.de>
> ---
> Another small fix from our FIPS evaluation. I hope you don't mind I merged
> arm32 and arm64 into one patch -- this is really simple.
> --- a/arch/arm/crypto/aes-neonbs-glue.c
> +++ b/arch/arm/crypto/aes-neonbs-glue.c
> @@ -138,6 +138,7 @@ static int aesbs_cbc_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
>  	kernel_neon_begin();
>  	aesbs_convert_key(ctx->key.rk, rk.key_enc, ctx->key.rounds);
>  	kernel_neon_end();
> +	memzero_explicit(&rk, sizeof(rk));
>  
>  	return crypto_cipher_setkey(ctx->enc_tfm, in_key, key_len);
>  }
> diff --git a/arch/arm64/crypto/aes-neonbs-glue.c b/arch/arm64/crypto/aes-neonbs-glue.c
> index e3e27349a9fe..c0b980503643 100644
> --- a/arch/arm64/crypto/aes-neonbs-glue.c
> +++ b/arch/arm64/crypto/aes-neonbs-glue.c
> @@ -151,6 +151,7 @@ static int aesbs_cbc_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
>  	kernel_neon_begin();
>  	aesbs_convert_key(ctx->key.rk, rk.key_enc, ctx->key.rounds);
>  	kernel_neon_end();
> +	memzero_explicit(&rk, sizeof(rk));
>  
>  	return 0;
>  }

I'm certainly not a crypto person, but this looks sensible to me and I
couldn't find any other similar stack variable usage under
arch/arm64/crypto/ at a quick glance.

Acked-by: Will Deacon <will@kernel.org>

Will

  reply	other threads:[~2020-03-17 22:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-13 11:02 [Patch][Fix] crypto: arm{,64} neon: memzero_explicit aes-cbc key Torsten Duwe
2020-03-17 22:17 ` Will Deacon [this message]
2020-03-18 20:13   ` Ard Biesheuvel
2020-03-19  8:15     ` Will Deacon
2020-03-20  3:51 ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200317221743.GD20788@willie-the-truck \
    --to=will@kernel.org \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=davem@davemloft.net \
    --cc=duwe@lst.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).