lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250701123521.GA2835771@ax162>
Date: Tue, 1 Jul 2025 05:35:21 -0700
From: Nathan Chancellor <nathan@...nel.org>
To: Kees Cook <kees@...nel.org>
Cc: Jannik Glückert <jannik.glueckert@...il.com>,
	linux-hardening@...r.kernel.org,
	Nick Desaulniers <nick.desaulniers+lkml@...il.com>,
	Bill Wendling <morbo@...gle.com>,
	Justin Stitt <justinstitt@...gle.com>, linux-kernel@...r.kernel.org,
	llvm@...ts.linux.dev
Subject: Re: [PATCH] kunit/fortify: Add back "volatile" for sizeof() constants

On Sat, Jun 28, 2025 at 04:40:38PM -0700, Kees Cook wrote:
> It seems the Clang can see through OPTIMIZER_HIDE_VAR when the constant
> is coming from sizeof. Adding "volatile" back to these variables solves
> this false positive without reintroducing the issues that originally led
> to switching to OPTIMIZER_HIDE_VAR in the first place[1].
> 
> Reported-by: Nathan Chancellor <nathan@...nel.org>
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2075 [1]
> Cc: "Jannik Glückert" <jannik.glueckert@...il.com>
> Suggested-by: Nathan Chancellor <nathan@...nel.org>
> Fixes: 6ee149f61bcc ("kunit/fortify: Replace "volatile" with OPTIMIZER_HIDE_VAR()")
> Signed-off-by: Kees Cook <kees@...nel.org>

Reviewed-by: Nathan Chancellor <nathan@...nel.org>

> ---
> Cc: <linux-hardening@...r.kernel.org>
> ---
>  lib/tests/fortify_kunit.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/tests/fortify_kunit.c b/lib/tests/fortify_kunit.c
> index 29ffc62a71e3..fc9c76f026d6 100644
> --- a/lib/tests/fortify_kunit.c
> +++ b/lib/tests/fortify_kunit.c
> @@ -1003,8 +1003,8 @@ static void fortify_test_memcmp(struct kunit *test)
>  {
>  	char one[] = "My mind is going ...";
>  	char two[] = "My mind is going ... I can feel it.";
> -	size_t one_len = sizeof(one) - 1;
> -	size_t two_len = sizeof(two) - 1;
> +	volatile size_t one_len = sizeof(one) - 1;
> +	volatile size_t two_len = sizeof(two) - 1;
>  
>  	OPTIMIZER_HIDE_VAR(one_len);
>  	OPTIMIZER_HIDE_VAR(two_len);
> -- 
> 2.34.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ