linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	linux-crypto@vger.kernel.org, llvm@lists.linux.dev,
	patches@lists.linux.dev
Subject: Re: [PATCH] crypto: lib/curve25519-hacl64 - Disable KASAN with clang-17 and older
Date: Tue, 10 Jun 2025 11:42:37 -0700	[thread overview]
Message-ID: <20250610184237.GB1649@sol> (raw)
In-Reply-To: <20250609-curve25519-hacl64-disable-kasan-clang-v1-1-08ea0ac5ccff@kernel.org>

On Mon, Jun 09, 2025 at 03:45:20PM -0700, Nathan Chancellor wrote:
> After commit 6f110a5e4f99 ("Disable SLUB_TINY for build testing"), which
> causes CONFIG_KASAN to be enabled in allmodconfig again, arm64
> allmodconfig builds with clang-17 and older show an instance of
> -Wframe-larger-than (which breaks the build with CONFIG_WERROR=y):
> 
>   lib/crypto/curve25519-hacl64.c:757:6: error: stack frame size (2336) exceeds limit (2048) in 'curve25519_generic' [-Werror,-Wframe-larger-than]
>     757 | void curve25519_generic(u8 mypublic[CURVE25519_KEY_SIZE],
>         |      ^
> 
> When KASAN is disabled, the stack usage is roughly quartered:
> 
>   lib/crypto/curve25519-hacl64.c:757:6: error: stack frame size (608) exceeds limit (128) in 'curve25519_generic' [-Werror,-Wframe-larger-than]
>     757 | void curve25519_generic(u8 mypublic[CURVE25519_KEY_SIZE],
>         |      ^
> 
> Using '-Rpass-analysis=stack-frame-layout' shows the following variables
> and many, many 8-byte spills when KASAN is enabled:
> 
>   Offset: [SP-144], Type: Variable, Align: 8, Size: 40
>   Offset: [SP-464], Type: Variable, Align: 8, Size: 320
>   Offset: [SP-784], Type: Variable, Align: 8, Size: 320
>   Offset: [SP-864], Type: Variable, Align: 32, Size: 80
>   Offset: [SP-896], Type: Variable, Align: 32, Size: 32
>   Offset: [SP-1016], Type: Variable, Align: 8, Size: 120
> 
> When KASAN is disabled, there are still spills but not at many and the
> variables list is smaller:
> 
>   Offset: [SP-192], Type: Variable, Align: 32, Size: 80
>   Offset: [SP-224], Type: Variable, Align: 32, Size: 32
>   Offset: [SP-344], Type: Variable, Align: 8, Size: 120
> 
> Disable KASAN for this file when using clang-17 or older to avoid
> blowing out the stack, clearing up the warning.
> 
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  lib/crypto/Makefile | 4 ++++
>  1 file changed, 4 insertions(+)
> 

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-fixes

Thanks!

- Eric

      parent reply	other threads:[~2025-06-10 18:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-09 22:45 [PATCH] crypto: lib/curve25519-hacl64 - Disable KASAN with clang-17 and older Nathan Chancellor
2025-06-10  9:42 ` Ard Biesheuvel
2025-06-10 17:41 ` Jason A. Donenfeld
2025-06-10 18:42 ` Eric Biggers [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250610184237.GB1649@sol \
    --to=ebiggers@kernel.org \
    --cc=Jason@zx2c4.com \
    --cc=ardb@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=patches@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).