[PATCH 0/2] x86: replace stack cookie hack with named address space

From: Ard Biesheuvel

Date: Fri Nov 27 2026 - 09:24:21 EST


From: Ard Biesheuvel <ardb@xxxxxxxxxx>

Currently, on x86, the C name of the stack check cookie per-CPU variable
is deliberately different from the one passed to the compiler command
line option -mstack-check-guard-symbol=

This was done to work around a Clang issue, where a non-TLS C
declaration of the variable results in Clang dropping the segment
prefixes.

As it turns out, all Clang versions that Linux supports today have some
support for address space annotations, and annotating the C declaration
with the correct address space is sufficient to coerce Clang into
generating the appropriate prefixes for the memory operands. This means
the linker and asm hacks can be dropped.

Patch #1 makes EXPORT_SYMBOL() work as expected for symbols with an
address space annotation, so that patch #2 can export __stack_chk_guard
normally, rather than from an unrelated .S file.

Cc: Uros Bizjak <ubizjak@xxxxxxxxx>
Cc: Nathan Chancellor <nathan@xxxxxxxxxx>
Cc: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
Cc: llvm@xxxxxxxxxxxxxxx

Ard Biesheuvel (2):
compiler.h: Use the symbol's own pointer type in __ADDRESSABLE()
x86/stackprotector: Use a named address space for the Clang stack
guard

arch/x86/Makefile | 2 +-
arch/x86/entry/entry.S | 14 ----------
arch/x86/include/asm/asm-prototypes.h | 4 ---
arch/x86/include/asm/percpu.h | 10 +++----
arch/x86/include/asm/stackprotector.h | 29 ++++++++++++++++++--
arch/x86/kernel/cpu/common.c | 4 +--
arch/x86/kernel/vmlinux.lds.S | 3 --
include/linux/compiler.h | 4 +--
8 files changed, 35 insertions(+), 35 deletions(-)

--
2.56.1.839.g22a8290db9-goog