From: Michael Ellerman <mpe@ellerman.id.au>
To: ndesaulniers@google.com, "Borislav Petkov (AMD)" <bp@alien8.de>
Cc: Peter Zijlstra <peterz@infradead.org>,
Josh Poimboeuf <jpoimboe@kernel.org>,
x86@kernel.org, Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Miguel Ojeda <ojeda@kernel.org>,
Nathan Chancellor <nathan@kernel.org>, Tom Rix <trix@redhat.com>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Nick Desaulniers <ndesaulniers@google.com>
Subject: Re: [PATCH 1/2] start_kernel: add no_stack_protector fn attr
Date: Fri, 14 Apr 2023 10:09:58 +1000 [thread overview]
Message-ID: <87r0sn9ve1.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <20230412-no_stackp-v1-1-46a69b507a4b@google.com>
ndesaulniers@google.com writes:
> Back during the discussion of
> commit a9a3ed1eff36 ("x86: Fix early boot crash on gcc-10, third try")
> we discussed the need for a function attribute to control the omission
> of stack protectors on a per-function basis; at the time Clang had
> support for no_stack_protector but GCC did not. This was fixed in
> gcc-11. Now that the function attribute is available, let's start using
> it.
>
> Callers of boot_init_stack_canary need to use this function attribute
> unless they're compiled with -fno-stack-protector, otherwise the canary
> stored in the stack slot of the caller will differ upon the call to
> boot_init_stack_canary. This will lead to a call to __stack_chk_fail
> then panic.
>
> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94722
> Link: https://lore.kernel.org/all/20200316130414.GC12561@hirez.programming.kicks-ass.net/
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> arch/powerpc/kernel/smp.c | 1 +
> include/linux/compiler_attributes.h | 12 ++++++++++++
> init/main.c | 3 ++-
> 3 files changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> index 6b90f10a6c81..7d4c12b1abb7 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -1603,6 +1603,7 @@ static void add_cpu_to_masks(int cpu)
> }
>
> /* Activate a secondary processor. */
> +__no_stack_protector
> void start_secondary(void *unused)
> {
> unsigned int cpu = raw_smp_processor_id();
start_secondary() doesn't return, so it won't actually crash, but it
obviously makes sense for it to be marked with __no_stack_protector.
There's quite a few other places we could add __no_stack_protector
annotations in powerpc code, and then make the changes to CFLAGS to
disable stack protector conditional on GCC < 11.
So I guess this patch is fine, but there's more that could be done.
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
cheers
next prev parent reply other threads:[~2023-04-14 0:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-12 18:32 [PATCH 0/2] start_kernel: omit stack canary ndesaulniers
2023-04-12 18:32 ` [PATCH 1/2] start_kernel: add no_stack_protector fn attr ndesaulniers
2023-04-12 20:22 ` Miguel Ojeda
2023-04-12 22:03 ` Nathan Chancellor
2023-04-14 0:09 ` Michael Ellerman [this message]
2023-04-12 18:32 ` [PATCH 2/2] start_kernel: omit prevent_tail_call_optimization for newer toolchains ndesaulniers
2023-04-12 22:04 ` Nathan Chancellor
2023-04-13 7:51 ` [PATCH 0/2] start_kernel: omit stack canary Peter Zijlstra
-- strict thread matches above, loose matches on Subject: below --
2023-04-17 21:54 ndesaulniers
2023-04-17 21:54 ` [PATCH 1/2] start_kernel: add no_stack_protector fn attr ndesaulniers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r0sn9ve1.fsf@mpe.ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=bp@alien8.de \
--cc=christophe.leroy@csgroup.eu \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=npiggin@gmail.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=trix@redhat.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox