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: <CAMj1kXGKDtWxcuWbPP+o=6_pwhOHKJF_NnOL8F95y0tXt-dQQg@mail.gmail.com>
Date: Fri, 21 Feb 2025 15:13:34 +0100
From: Ard Biesheuvel <ardb@...nel.org>
To: Uros Bizjak <ubizjak@...il.com>
Cc: Brian Gerst <brgerst@...il.com>, x86@...nel.org, linux-kernel@...r.kernel.org, 
	Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...nel.org>, Borislav Petkov <bp@...en8.de>, 
	Dave Hansen <dave.hansen@...ux.intel.com>, "H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH -tip] x86/stackprotector: Move stack canary to struct pcpu_hot

On Fri, 21 Feb 2025 at 15:02, Uros Bizjak <ubizjak@...il.com> wrote:
>
> On Fri, Feb 21, 2025 at 2:37 PM Brian Gerst <brgerst@...il.com> wrote:
> >
> > On Fri, Feb 21, 2025 at 8:25 AM Uros Bizjak <ubizjak@...il.com> wrote:
> > >
> > > On Fri, Feb 21, 2025 at 1:54 PM Brian Gerst <brgerst@...il.com> wrote:
> > > >
> > > > On Thu, Feb 20, 2025 at 3:04 PM Uros Bizjak <ubizjak@...il.com> wrote:
> > > > >
> > > > > Move stack canary from __stack_chk_guard to struct pcpu_hot and
> > > > > alias __stack_chk_guard to point to the new location in the
> > > > > linker script.
> > > > >
> > > > > __stack_chk_guard is one of the hottest data structures on x86, so
> > > > > moving it there makes sense even if its benefit cannot be measured
> > > > > explicitly.
> > > > >
> > > > > Signed-off-by: Uros Bizjak <ubizjak@...il.com>
> > > > > Cc: Thomas Gleixner <tglx@...utronix.de>
> > > > > Cc: Ingo Molnar <mingo@...nel.org>
> > > > > Cc: Borislav Petkov <bp@...en8.de>
> > > > > Cc: Dave Hansen <dave.hansen@...ux.intel.com>
> > > > > Cc: "H. Peter Anvin" <hpa@...or.com>
> > > > > Cc: Brian Gerst <brgerst@...il.com>
> > > > > Cc: Ard Biesheuvel <ardb@...nel.org>
> > > > > ---
> > > > >  arch/x86/include/asm/current.h | 13 +++++++++++++
> > > > >  arch/x86/kernel/cpu/common.c   |  1 -
> > > > >  arch/x86/kernel/vmlinux.lds.S  |  2 ++
> > > > >  3 files changed, 15 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/arch/x86/include/asm/current.h b/arch/x86/include/asm/current.h
> > > > > index bf5953883ec3..e4ff1d15b465 100644
> > > > > --- a/arch/x86/include/asm/current.h
> > > > > +++ b/arch/x86/include/asm/current.h
> > > > > @@ -15,6 +15,9 @@ struct task_struct;
> > > > >  struct pcpu_hot {
> > > > >         union {
> > > > >                 struct {
> > > > > +#ifdef CONFIG_STACKPROTECTOR
> > > > > +                       unsigned long           stack_canary;
> > > > > +#endif
> > > > >                         struct task_struct      *current_task;
> > > > >                         int                     preempt_count;
> > > > >                         int                     cpu_number;
> > > > > @@ -35,6 +38,16 @@ struct pcpu_hot {
> > > > >  };
> > > > >  static_assert(sizeof(struct pcpu_hot) == 64);
> > > > >
> > > > > +/*
> > > > > + * stack_canary should be at the beginning of struct pcpu_hot to avoid:
> > > > > + *
> > > > > + * Invalid absolute R_X86_64_32S relocation: __stack_chk_guard
> > > >
> > > > This should be R_X86_64_PC32 relocations.
> > >
> > > This is what the build system reports if any offset (including 0) is added to
> > >
> > > PROVIDE(__stack_chk_guard = pcpu_hot);
> > >
> > > It is not a warning, but an error that fails the build.
> > >
> > > As was discussed in the previous thread, the above is required to
> > > handle !SMP case, where mstack-protector-guard=global (used by !SMP
> > > builds) ignores the
> > > -mstack-protector-guard-symbol option and always uses __stack_chk_guard.
> >
> > I got a warning from the relocs tool, but not a hard error.  What
> > compiler/linker are you using?
> >
> > Does the attached patch build in your configuration?
>
> Ah, the attached patch is similar to my previous approach, where the
> build system *warned* on an offset (the patch was abandoned due to
> Ard's request to put stack_canary to the *beginning* of struct
> pcpu_hot, and this allowed for a simplified patch).
>
> The attached patch builds for me without warning/error for both, SMP
> and !SMP build.
>

Did you try building modules too?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ