[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABCJKucB2L7tdr79cDaDahGhc8nS6vp5fiURxoMs7z4f7yQW3Q@mail.gmail.com>
Date: Thu, 20 Mar 2025 16:14:09 -0700
From: Sami Tolvanen <samitolvanen@...gle.com>
To: Ard Biesheuvel <ardb@...nel.org>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org, brgerst@...il.com
Subject: Re: [PATCH] x86/asm: Make asm export of __ref_stack_chk_guard unconditional
On Thu, Mar 20, 2025 at 2:33 PM Ard Biesheuvel <ardb@...nel.org> wrote:
>
> Clang does not tolerate the use of non-TLS symbols for the per-CPU stack
> protector very well, and to work around this limitation, the symbol
> passed via the -mstack-protector-guard-symbol= option is never defined
> in C code, but only in the linker script, and it is exported from an
> assembly file. This is necessary because Clang will fail to generate the
> correct %GS based references in a compilation unit that includes a
> non-TLS definition of the guard symbol being used to store the stack
> cookie.
>
> This problem is only triggered by symbol definitions, not by
> declarations, but nonetheless, the declaration in <asm/asm-prototypes.h>
> is conditional on __GENKSYMS__ being #define'd, so that only genksyms
> will observe it, but for ordinary compilation, it will be invisible.
>
> This is causing problems with the genksyms alternative gendwarfksyms,
> which does not #define __GENKSYMS__, does not observe the symbol
> declaration, and therefore lacks the information it needs to version it.
> Adding the #define creates problems in other places, so that is not a
> straight-forward solution. So take the easy way out, and drop the
> conditional on __GENKSYMS__, as this is not really needed to begin with.
>
> Signed-off-by: Ard Biesheuvel <ardb@...nel.org>
> ---
> arch/x86/include/asm/asm-prototypes.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/include/asm/asm-prototypes.h b/arch/x86/include/asm/asm-prototypes.h
> index 8d9e62725202..11c6fecc3ad7 100644
> --- a/arch/x86/include/asm/asm-prototypes.h
> +++ b/arch/x86/include/asm/asm-prototypes.h
> @@ -20,6 +20,6 @@
> extern void cmpxchg8b_emu(void);
> #endif
>
> -#if defined(__GENKSYMS__) && defined(CONFIG_STACKPROTECTOR)
> +#ifdef CONFIG_STACKPROTECTOR
> extern unsigned long __ref_stack_chk_guard;
> #endif
LGTM.
Reviewed-by: Sami Tolvanen <samitolvanen@...gle.com>
Sami
Powered by blists - more mailing lists