[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMj1kXFAwnBi0EjRJaB-MpqPCmV+tYRN7Dw_PUJuxxrnaEnoKg@mail.gmail.com>
Date: Thu, 20 Feb 2025 10:23:38 +0100
From: Ard Biesheuvel <ardb@...nel.org>
To: Nathan Chancellor <nathan@...nel.org>
Cc: Brian Gerst <brgerst@...il.com>, linux-kernel@...r.kernel.org, x86@...nel.org,
Ingo Molnar <mingo@...nel.org>, "H . Peter Anvin" <hpa@...or.com>, Thomas Gleixner <tglx@...utronix.de>,
Borislav Petkov <bp@...en8.de>, Uros Bizjak <ubizjak@...il.com>, llvm@...ts.linux.dev
Subject: Re: [PATCH v6 07/15] x86/stackprotector/64: Convert to normal percpu variable
On Wed, 19 Feb 2025 at 20:59, Nathan Chancellor <nathan@...nel.org> wrote:
>
> On Thu, Jan 23, 2025 at 02:07:39PM -0500, Brian Gerst wrote:
> > Older versions of GCC fixed the location of the stack protector canary
> > at %gs:40. This constraint forced the percpu section to be linked at
> > absolute address 0 so that the canary could be the first data object in
> > the percpu section. Supporting the zero-based percpu section requires
> > additional code to handle relocations for RIP-relative references to
> > percpu data, extra complexity to kallsyms, and workarounds for linker
> > bugs due to the use of absolute symbols.
> >
> > GCC 8.1 supports redefining where the canary is located, allowng it to
> > become a normal percpu variable instead of at a fixed location. This
> > removes the contraint that the percpu section must be zero-based.
> >
> > Signed-off-by: Brian Gerst <brgerst@...il.com>
> > Reviewed-by: Ard Biesheuvel <ardb@...nel.org>
> > Reviewed-by: Uros Bizjak <ubizjak@...il.com>
> ...
> > diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> > index 5b773b34768d..88a1705366f9 100644
> > --- a/arch/x86/Makefile
> > +++ b/arch/x86/Makefile
> > @@ -140,14 +140,7 @@ ifeq ($(CONFIG_X86_32),y)
> > # temporary until string.h is fixed
> > KBUILD_CFLAGS += -ffreestanding
> >
> > - ifeq ($(CONFIG_STACKPROTECTOR),y)
> > - ifeq ($(CONFIG_SMP),y)
> > - KBUILD_CFLAGS += -mstack-protector-guard-reg=fs \
> > - -mstack-protector-guard-symbol=__ref_stack_chk_guard
> > - else
> > - KBUILD_CFLAGS += -mstack-protector-guard=global
> > - endif
> > - endif
> > + percpu_seg := fs
> > else
> > BITS := 64
> > UTS_MACHINE := x86_64
> > @@ -197,6 +190,17 @@ else
> > KBUILD_CFLAGS += -mcmodel=kernel
> > KBUILD_RUSTFLAGS += -Cno-redzone=y
> > KBUILD_RUSTFLAGS += -Ccode-model=kernel
> > +
> > + percpu_seg := gs
> > +endif
> > +
> > +ifeq ($(CONFIG_STACKPROTECTOR),y)
> > + ifeq ($(CONFIG_SMP),y)
> > + KBUILD_CFLAGS += -mstack-protector-guard-reg=$(percpu_seg)
> > + KBUILD_CFLAGS += -mstack-protector-guard-symbol=__ref_stack_chk_guard
> > + else
> > + KBUILD_CFLAGS += -mstack-protector-guard=global
> > + endif
> > endif
>
> -mstack-protector-guard-symbol was only added in clang-15, so it looks
> like min-tool-version.sh will need an adjustment like GCC did, should I
> send a patch?
>
Yes, please.
Powered by blists - more mailing lists