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: <Yw+8QgtSbB2/3Eiq@dev-arch.thelio-3990X>
Date:   Wed, 31 Aug 2022 12:53:38 -0700
From:   Nathan Chancellor <nathan@...nel.org>
To:     Nick Desaulniers <ndesaulniers@...gle.com>
Cc:     Masahiro Yamada <masahiroy@...nel.org>,
        Michal Marek <michal.lkml@...kovi.net>,
        Tom Rix <trix@...hat.com>, linux-kbuild@...r.kernel.org,
        linux-kernel@...r.kernel.org, llvm@...ts.linux.dev, x86@...nel.org,
        Dmitrii Bundin <dmitrii.bundin.a@...il.com>,
        Fangrui Song <maskray@...gle.com>,
        Alexey Alexandrov <aalexand@...gle.com>,
        Bill Wendling <morbo@...gle.com>,
        Greg Thelen <gthelen@...gle.com>
Subject: Re: [PATCH v2 2/5] Makefile.compiler: Use KBUILD_AFLAGS for as-option

On Wed, Aug 31, 2022 at 11:44:05AM -0700, Nick Desaulniers wrote:
> as-instr uses KBUILD_AFLAGS, but as-option uses KBUILD_CFLAGS.  This can
> cause as-option to fail unexpectedly because clang will emit
> -Werror,-Wunused-command-line-argument for various -m and -f flags for
> assembler sources.

Now that I am looking closer at it, where does that '-Werror' come from?
For cc-option, we add it to elevate clang's warnings about unused '-f',
'-m', and '-W' flags to errors so that we do not add those flags.
However, I do not see '-Werror' in as-option. I am going to assume it
came from CONFIG_WERROR, as I believe Android has that turned on by
default. I think that is the real problem: without '-Werror', the only
error that should come from as-option is when an option isn't supported
by the assembler, as clang will still warn but those will not be fatal
but with '-Werror', those warnings turn fatal, causing all subsequent
as-option calls to fail.

Do not get me wrong, I still believe this is the correct fix but I think
it would be good to describe exactly under which conditions this is a
real issue in case we ever have to revisit this.

> Callers of as-option (and as-instr) likely want to be adding flags to
> KBUILD_AFLAGS/aflags-y, not KBUILD_CFLAGS/cflags-y.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/1699
> Signed-off-by: Nick Desaulniers <ndesaulniers@...gle.com>

Regardless of changes to the commit message:

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

> ---
> Changes v1 -> v2:
> * Split off changes to arch/x86/boot/compressed/Makefile into parent
>   patch, as per Masahiro.
> 
>  scripts/Makefile.compiler | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler
> index 94d0d40cddb3..d1739f0d3ce3 100644
> --- a/scripts/Makefile.compiler
> +++ b/scripts/Makefile.compiler
> @@ -29,13 +29,13 @@ try-run = $(shell set -e;		\
>  	fi)
>  
>  # as-option
> -# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
> +# Usage: aflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
>  
>  as-option = $(call try-run,\
> -	$(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2))
> +	$(CC) $(KBUILD_AFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2))
>  
>  # as-instr
> -# Usage: cflags-y += $(call as-instr,instr,option1,option2)
> +# Usage: aflags-y += $(call as-instr,instr,option1,option2)
>  
>  as-instr = $(call try-run,\
>  	printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
> -- 
> 2.37.2.672.g94769d06f0-goog
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ