diff mbox series

crypto: lib/aesgcm - Reduce stack usage in libaesgcm_init

Message ID Z2bWK_JKxKvwOpTM@gondor.apana.org.au (mailing list archive)
State New
Headers show
Series crypto: lib/aesgcm - Reduce stack usage in libaesgcm_init | expand

Commit Message

Herbert Xu Dec. 21, 2024, 2:52 p.m. UTC
The stack frame in libaesgcm_init triggers a size warning on x86-64.
Reduce it by making buf static.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Comments

Ard Biesheuvel Dec. 21, 2024, 3:45 p.m. UTC | #1
On Sat, 21 Dec 2024 at 15:52, Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> The stack frame in libaesgcm_init triggers a size warning on x86-64.
> Reduce it by making buf static.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
>

Acked-by: Ard Biesheuvel <ardb@kernel.org>

> diff --git a/lib/crypto/aesgcm.c b/lib/crypto/aesgcm.c
> index 6bba6473fdf3..902e49410aaf 100644
> --- a/lib/crypto/aesgcm.c
> +++ b/lib/crypto/aesgcm.c
> @@ -697,7 +697,7 @@ static int __init libaesgcm_init(void)
>                 u8 tagbuf[AES_BLOCK_SIZE];
>                 int plen = aesgcm_tv[i].plen;
>                 struct aesgcm_ctx ctx;
> -               u8 buf[sizeof(ptext12)];
> +               static u8 buf[sizeof(ptext12)];
>
>                 if (aesgcm_expandkey(&ctx, aesgcm_tv[i].key, aesgcm_tv[i].klen,
>                                      aesgcm_tv[i].clen - plen)) {
> --
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
diff mbox series

Patch

diff --git a/lib/crypto/aesgcm.c b/lib/crypto/aesgcm.c
index 6bba6473fdf3..902e49410aaf 100644
--- a/lib/crypto/aesgcm.c
+++ b/lib/crypto/aesgcm.c
@@ -697,7 +697,7 @@  static int __init libaesgcm_init(void)
 		u8 tagbuf[AES_BLOCK_SIZE];
 		int plen = aesgcm_tv[i].plen;
 		struct aesgcm_ctx ctx;
-		u8 buf[sizeof(ptext12)];
+		static u8 buf[sizeof(ptext12)];
 
 		if (aesgcm_expandkey(&ctx, aesgcm_tv[i].key, aesgcm_tv[i].klen,
 				     aesgcm_tv[i].clen - plen)) {