linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: ccree - reduce kernel stack usage with clang
@ 2019-03-14  9:09 Arnd Bergmann
  2019-03-17  6:06 ` Gilad Ben-Yossef
  2019-03-22 13:04 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2019-03-14  9:09 UTC (permalink / raw)
  To: Gilad Ben-Yossef, Herbert Xu, David S. Miller
  Cc: Arnd Bergmann, Eric Biggers, Gustavo A. R. Silva, linux-crypto,
	linux-kernel

Building with clang for a 32-bit architecture runs over the stack
frame limit in the setkey function:

drivers/crypto/ccree/cc_cipher.c:318:12: error: stack frame size of 1152 bytes in function 'cc_cipher_setkey' [-Werror,-Wframe-larger-than=]

The problem is that there are two large variables: the temporary
'tmp' array and the SHASH_DESC_ON_STACK() declaration. Moving
the first into the block in which it is used reduces the
total frame size to 768 bytes, which seems more reasonable
and is under the warning limit.

Fixes: 63ee04c8b491 ("crypto: ccree - add skcipher support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/crypto/ccree/cc_cipher.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
index d9c17078517b..0abcdc224ab0 100644
--- a/drivers/crypto/ccree/cc_cipher.c
+++ b/drivers/crypto/ccree/cc_cipher.c
@@ -321,7 +321,6 @@ static int cc_cipher_setkey(struct crypto_skcipher *sktfm, const u8 *key,
 	struct crypto_tfm *tfm = crypto_skcipher_tfm(sktfm);
 	struct cc_cipher_ctx *ctx_p = crypto_tfm_ctx(tfm);
 	struct device *dev = drvdata_to_dev(ctx_p->drvdata);
-	u32 tmp[DES3_EDE_EXPKEY_WORDS];
 	struct cc_crypto_alg *cc_alg =
 			container_of(tfm->__crt_alg, struct cc_crypto_alg,
 				     skcipher_alg.base);
@@ -347,6 +346,7 @@ static int cc_cipher_setkey(struct crypto_skcipher *sktfm, const u8 *key,
 	 * HW does the expansion on its own.
 	 */
 	if (ctx_p->flow_mode == S_DIN_to_DES) {
+		u32 tmp[DES3_EDE_EXPKEY_WORDS];
 		if (keylen == DES3_EDE_KEY_SIZE &&
 		    __des3_ede_setkey(tmp, &tfm->crt_flags, key,
 				      DES3_EDE_KEY_SIZE)) {
-- 
2.20.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: ccree - reduce kernel stack usage with clang
  2019-03-14  9:09 [PATCH] crypto: ccree - reduce kernel stack usage with clang Arnd Bergmann
@ 2019-03-17  6:06 ` Gilad Ben-Yossef
  2019-03-22 13:04 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Gilad Ben-Yossef @ 2019-03-17  6:06 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Herbert Xu, David S. Miller, Eric Biggers, Gustavo A. R. Silva,
	Linux Crypto Mailing List, Linux kernel mailing list

On Thu, Mar 14, 2019 at 11:10 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> Building with clang for a 32-bit architecture runs over the stack
> frame limit in the setkey function:
>
> drivers/crypto/ccree/cc_cipher.c:318:12: error: stack frame size of 1152 bytes in function 'cc_cipher_setkey' [-Werror,-Wframe-larger-than=]
>
> The problem is that there are two large variables: the temporary
> 'tmp' array and the SHASH_DESC_ON_STACK() declaration. Moving
> the first into the block in which it is used reduces the
> total frame size to 768 bytes, which seems more reasonable
> and is under the warning limit.
>

Thank you , Ard.

I will also revisit splitting that function to further reduce stack
usage after I finish tackling the fallout of the new testmgr... :-)

Acked-By: Gilad Ben-Yossef <gilad@benyossef.com>

Gilad
-- 
Gilad Ben-Yossef
Chief Coffee Drinker

values of β will give rise to dom!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: ccree - reduce kernel stack usage with clang
  2019-03-14  9:09 [PATCH] crypto: ccree - reduce kernel stack usage with clang Arnd Bergmann
  2019-03-17  6:06 ` Gilad Ben-Yossef
@ 2019-03-22 13:04 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2019-03-22 13:04 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Gilad Ben-Yossef, David S. Miller, Eric Biggers,
	Gustavo A. R. Silva, linux-crypto, linux-kernel

On Thu, Mar 14, 2019 at 10:09:44AM +0100, Arnd Bergmann wrote:
> Building with clang for a 32-bit architecture runs over the stack
> frame limit in the setkey function:
> 
> drivers/crypto/ccree/cc_cipher.c:318:12: error: stack frame size of 1152 bytes in function 'cc_cipher_setkey' [-Werror,-Wframe-larger-than=]
> 
> The problem is that there are two large variables: the temporary
> 'tmp' array and the SHASH_DESC_ON_STACK() declaration. Moving
> the first into the block in which it is used reduces the
> total frame size to 768 bytes, which seems more reasonable
> and is under the warning limit.
> 
> Fixes: 63ee04c8b491 ("crypto: ccree - add skcipher support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/crypto/ccree/cc_cipher.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Patch applied.  Thanks.
-- 
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-22 13:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14  9:09 [PATCH] crypto: ccree - reduce kernel stack usage with clang Arnd Bergmann
2019-03-17  6:06 ` Gilad Ben-Yossef
2019-03-22 13:04 ` Herbert Xu

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).