From patchwork Sun Mar 24 19:44:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 161012 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3161470jan; Sun, 24 Mar 2019 12:45:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1huyXYjighNDQ0SGQ2RU4e5NqTTZ9J6zJKTOlEJvWCjCvAdmtLULYTEOYJaw9KAbFDzFM X-Received: by 2002:a17:902:4383:: with SMTP id j3mr3530994pld.58.1553456748947; Sun, 24 Mar 2019 12:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553456748; cv=none; d=google.com; s=arc-20160816; b=xCR6PQtsCn7QR/avyYsdqSpV+enB1+aH8850DZdRlKOaFmXpoXNmzYbCkiLytKUPQL YqfZXvuHZHwySxx8kJu/CkM0aZzF4bt+BsL2INLOf6tpqEVcsRMV8G8yGL8AYOm9BrrE 7uU3+FCc50OAwOskNDNcSL5759jpYRel2qEkwwMdbe2qZAN11EhLm6khTR6Eg/ARQbPU yaKS3or9UdXMUE5VZCjSxYh+Pm4MVgLdYGj6bv4Jb5FpvrWC0BP7BxS1aplqAklJCIQG OMRiA9W640wCdw74PXoGVX0XZdKdt8+LBMHfYZ8yQesP/PNVmcFZuvlOZs4UhZVkaeUI Lqtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=8DgDqskYIvTbR2D1aQmj3fnrIbC4+W9yGYPvuEQc8Kk=; b=zBmWeuIuTFX054cVU8Qd5Tx5HVfAJydy0LQ1PQi7I4+JHLlmWUbNY3Id6xN9R0Gi0p NlK+5IsvU5EkszyzaEBvO+PxqiZtlNrJlkqHzaw3mkpq03heBM4ZFDMVJrFdw45l/YXs 5ZXLE9BudGqTFlE4Pv6qQfD7o9wvCsQkMS2UuwpOCMZM52rRTyUFPPouVCziMgp3vh9Z LLL1DS9jvYYtGRHlhwkdRBvCzhAy/Vi+YJPBrWpCOjRuFC+fwx2runhijY3uufjAFgGc WPYqVUEL7V3kottj3b/3oTG5eojuHLMZOY1RQmllIDAdQ64I00XVE2LcVyoSB+7FwGLD baUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g35si11821105pgm.540.2019.03.24.12.45.48; Sun, 24 Mar 2019 12:45:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728361AbfCXTpm (ORCPT + 31 others); Sun, 24 Mar 2019 15:45:42 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:54447 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726743AbfCXTpm (ORCPT ); Sun, 24 Mar 2019 15:45:42 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MIx7U-1hRJXC4Aws-00KR5b; Sun, 24 Mar 2019 20:45:09 +0100 From: Arnd Bergmann To: Richard Weinberger , Artem Bityutskiy , Adrian Hunter Cc: clang-built-linux@googlegroups.com, Nick Desaulniers , Nathan Chancellor , Arnd Bergmann , Eric Biggers , Herbert Xu , Sascha Hauer , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] ubifs: work around high stack usage with clang Date: Sun, 24 Mar 2019 20:44:51 +0100 Message-Id: <20190324194505.3244479-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:YCZ4t4TKytA+xgmmV/ZeoVdXaCcLMykTcd/+MqVgKK9RGQVFZkk +k7Pc/E9cLc1rLgM26mCQ2Iroecuntrd+sk+4cID9SU7y4zy8dmcIkiIhBEuMrrXvxclSoB JsPFcKWlxMXCh+K17vhnsbena8D2r2Au5wSfQRAaFHlWTjN3EEf4Zt/uTxHTxtdImMcKfZO +XqSM09rswT2VTr7OiILg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:l1dFlghIaU4=:8fIJOYjmDOXT2bqE+tL4E0 VXUgvmJ4S4eKXpgYqbDmTgpgOB32HQo6Ql21y0tLyw2fmC/8BzpYpwDBvKOFklE+NdzDbx7my +HNTsKid8rJCFqUwT1CGI4ohiZesGGnOSleQg3XWN3feuqfbvoPpS9Xv55qtzSbPyy1o2vSf5 gwdClwqQlerzhpcmXLe5EoG2I0fuQQVUhExF84yihpg2xannrn0/XaZypI/qF2GWnTc6BpgVr AZHzjSMBHeKdEqXKQzgI+lA3IFIJdisR00yK4MpGsQzOb8kI7s79iR16JpNni5AVK8nDc5TNE dx0CsBww1mn3d3bNmvi9mfwpv/WcvDgDUsfHusitDMl9EmchqQI339si/RvRluI6DA6Zl2U2y 2md1vIi7w1wEoSLNf0YLL/1APxcmdSgiEPJh3NoZqJTiEb0+cx4OJSoAqoq0xmJQSCekbvr7m VGL71qsxbvGJyVcfKRAtTg15I4jrA1hhi9NOsD4JsILU6+VJxBfdfK95EOpzFBMf35YvPb5un YP2LjLdo/3ksCVDWAZk5kDLq8PcIHq4yEUMAoslO+VQf15bn6MMPmSkDomewWI8bzIVRRtfMt 2vRMwuB4Y+hm2K9RBOil3SIRVJSBgQzN7xzEQUWAqxTTLPBF8uD70XGfNJA39FKOxPD/NqEia GfAvs54Hvq7NvPGCck9ceH8JbeNMJd3AMuiIq4IrjTvy/3F4/Cv4GpHPXj72rfo5pS/X7na4i gfn1lWK6Rw676RXAxhnDoK/jMaMRNhucdBjGkQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- fs/ubifs/auth.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) -- 2.20.0 Reviewed-by: Nick Desaulniers diff --git a/fs/ubifs/auth.c b/fs/ubifs/auth.c index 5bf5fd08879e..5d3d0b37a908 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)