Re: [PATCH v2] crypto: inside-secure - Zeroize temporary arrays on stack with sensitive data
From: Antoine Tenart
Date: Wed Aug 19 2026 - 07:44:21 EST
On Wed, Aug 19, 2026 at 12:58:36PM +0200, Thomas Huth wrote:
> key_tmp[] in safexcel_xcbcmac_setkey() and consts[] / _const[] in
> safexcel_cmac_setkey() contain crypto key material that should not
> get exposed to the outside once the function is done. Scrub the
> arrays with memzero_explicit() to avoid that the data could leak
> via the stack.
>
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Link: https://sashiko.dev/#/patchset/20260813134953.979481-1-thuth%40redhat.com
> Fixes: 38f21b4bab11f ("crypto: inside-secure - Added support for the AES XCBC ahash")
> Fixes: 7a627db9cafdb ("crypto: inside-secure - Added support for the AES-CMAC ahash")
> Acked-by: Antoine Tenart <atenart@xxxxxxxxxx>
> Signed-off-by: Thomas Huth <thuth@xxxxxxxxxx>
> ---
> v2: Added "Fixes:" and "Reported-by:" tags
>
> drivers/crypto/inside-secure/safexcel_hash.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c
> index 3402e570d045c..1ae6fbec31298 100644
> --- a/drivers/crypto/inside-secure/safexcel_hash.c
> +++ b/drivers/crypto/inside-secure/safexcel_hash.c
> @@ -1993,6 +1993,7 @@ static int safexcel_xcbcmac_setkey(struct crypto_ahash *tfm, const u8 *key,
> ret = aes_prepareenckey(ctx->aes,
> (u8 *)key_tmp + 2 * AES_BLOCK_SIZE,
> AES_MIN_KEY_SIZE);
> + memzero_explicit(key_tmp, sizeof(key_tmp));
> if (ret)
> return ret;
>
> @@ -2104,6 +2105,9 @@ static int safexcel_cmac_setkey(struct crypto_ahash *tfm, const u8 *key,
> }
> ctx->cbcmac = false;
>
> +
Sorry, I just noticed there's an extra empty line here.
> + memzero_explicit(consts, sizeof(consts));
> + memzero_explicit(_const, sizeof(_const));
> return 0;
> }
>
> --
> 2.55.0
>