diff options
author | Arnd Bergmann <arnd@arndb.de> | 2019-03-24 20:44:51 +0100 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2019-05-07 21:36:39 +0200 |
commit | f4844b35d68ab49c41d542c501fffb46ad81009a (patch) | |
tree | ba3a0defe190b28fabc143601fe5a79f45b511bc /fs/ubifs | |
parent | ubifs: remove unused function __ubifs_shash_final (diff) | |
download | linux-f4844b35d68ab49c41d542c501fffb46ad81009a.tar.xz linux-f4844b35d68ab49c41d542c501fffb46ad81009a.zip |
ubifs: work around high stack usage with clang
Building this file with clang can result in large stack usage as seen from
this warning:
fs/ubifs/auth.c:78:5: error: stack frame size of 1152 bytes in function 'ubifs_prepare_auth_node'
The problem is that inlining ubifs_hash_calc_hmac() leads to
two SHASH_DESC_ON_STACK() blocks in the same function, and clang
for some reason does not reuse the stack space as it should.
Putting the first declaration into a separate basic block avoids
this problem and reduces the stack allocation to 640 bytes.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'fs/ubifs')
-rw-r--r-- | fs/ubifs/auth.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/ubifs/auth.c b/fs/ubifs/auth.c index 2a40cccee5bd..3d049194afa4 100644 --- a/fs/ubifs/auth.c +++ b/fs/ubifs/auth.c @@ -78,7 +78,6 @@ static int ubifs_hash_calc_hmac(const struct ubifs_info *c, const u8 *hash, int ubifs_prepare_auth_node(struct ubifs_info *c, void *node, struct shash_desc *inhash) { - SHASH_DESC_ON_STACK(hash_desc, c->hash_tfm); struct ubifs_auth_node *auth = node; u8 *hash; int err; @@ -87,13 +86,17 @@ int ubifs_prepare_auth_node(struct ubifs_info *c, void *node, if (!hash) return -ENOMEM; - hash_desc->tfm = c->hash_tfm; - hash_desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; - ubifs_shash_copy_state(c, inhash, hash_desc); + { + SHASH_DESC_ON_STACK(hash_desc, c->hash_tfm); - err = crypto_shash_final(hash_desc, hash); - if (err) - goto out; + hash_desc->tfm = c->hash_tfm; + hash_desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; + ubifs_shash_copy_state(c, inhash, hash_desc); + + err = crypto_shash_final(hash_desc, hash); + if (err) + goto out; + } err = ubifs_hash_calc_hmac(c, hash, auth->hmac); if (err) |