Skip to contentSkip to conversation

crypto: lib/aesgcm - Reduce stack usage in libaesgcm_init

PATCH In review Herbert Xu 2 participants 2 messages Dec 21, 2024

Subsystems (2)
lore
Share & tools
lore

Herbert Xu

author maintainer
#0 lore raw

PATCH 1/1 crypto: lib/aesgcm - Reduce stack usage in libaesgcm_init

The stack frame in libaesgcm_init triggers a size warning on x86-64. Reduce it by making buf static.

lib/crypto/aesgcm.c +1 -1
index 6bba6473fdf3..902e49410aaf 100644
@@ -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)) {
Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Herbert Xu

The stack frame in libaesgcm_init triggers a size warning on x86-64. Reduce it by making buf static.

Quoted 17 lines
lib/crypto/aesgcm.c +1 -2
index 6bba6473fdf3..902e49410aaf 100644
@@ -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 <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt