[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <875z6tw9gr.fsf@mpe.ellerman.id.au>
Date: Thu, 29 Oct 2020 22:35:48 +1100
From: Michael Ellerman <mpe@...erman.id.au>
To: Ard Biesheuvel <ardb@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Cc: "open list\:LINUX FOR POWERPC \(32-BIT AND 64-BIT\)"
<linuxppc-dev@...ts.ozlabs.org>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Arvind Sankar <nivedita@...m.mit.edu>,
Randy Dunlap <rdunlap@...radead.org>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Peter Zijlstra <peterz@...radead.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Kees Cook <keescook@...omium.org>
Subject: Re: [PATCH] powerpc: avoid broken GCC __attribute__((optimize))
Ard Biesheuvel <ardb@...nel.org> writes:
> On Wed, 28 Oct 2020 at 09:04, Ard Biesheuvel <ardb@...nel.org> wrote:
>>
>> Commit 7053f80d9696 ("powerpc/64: Prevent stack protection in early boot")
>> introduced a couple of uses of __attribute__((optimize)) with function
>> scope, to disable the stack protector in some early boot code.
>>
>> Unfortunately, and this is documented in the GCC man pages [0], overriding
>> function attributes for optimization is broken, and is only supported for
>> debug scenarios, not for production: the problem appears to be that
>> setting GCC -f flags using this method will cause it to forget about some
>> or all other optimization settings that have been applied.
>>
>> So the only safe way to disable the stack protector is to disable it for
>> the entire source file.
>>
>> [0] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
>>
>> Cc: Michael Ellerman <mpe@...erman.id.au>
>> Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>
>> Cc: Paul Mackerras <paulus@...ba.org>
>> Cc: Nick Desaulniers <ndesaulniers@...gle.com>
>> Cc: Arvind Sankar <nivedita@...m.mit.edu>
>> Cc: Randy Dunlap <rdunlap@...radead.org>
>> Cc: Josh Poimboeuf <jpoimboe@...hat.com>
>> Cc: Thomas Gleixner <tglx@...utronix.de>
>> Cc: Alexei Starovoitov <ast@...nel.org>
>> Cc: Daniel Borkmann <daniel@...earbox.net>
>> Cc: Peter Zijlstra (Intel) <peterz@...radead.org>
>> Cc: Geert Uytterhoeven <geert@...ux-m68k.org>
>> Cc: Kees Cook <keescook@...omium.org>
>> Fixes: 7053f80d9696 ("powerpc/64: Prevent stack protection in early boot")
>> Signed-off-by: Ard Biesheuvel <ardb@...nel.org>
>> ---
>> Related discussion here:
>> https://lore.kernel.org/lkml/CAMuHMdUg0WJHEcq6to0-eODpXPOywLot6UD2=GFHpzoj_hCoBQ@mail.gmail.com/
>>
>> TL;DR using __attribute__((optimize("-fno-gcse"))) in the BPF interpreter
>> causes the compiler to forget about -fno-asynchronous-unwind-tables passed
>> on the command line, resulting in unexpected .eh_frame sections in vmlinux.
>>
>> arch/powerpc/kernel/Makefile | 3 +++
>> arch/powerpc/kernel/paca.c | 2 +-
>> arch/powerpc/kernel/setup.h | 6 ------
>> arch/powerpc/kernel/setup_64.c | 2 +-
>> 4 files changed, 5 insertions(+), 8 deletions(-)
Thanks for the patch.
> FYI i was notified by one of the robots that I missed one occurrence
> of __nostackprotector in arch/powerpc/kernel/paca.c
>
> Let me know if I need to resend.
That's fine I'll fix it up when applying.
With the existing code, with STACKPROTECTOR_STRONG=y, I see two
functions in setup_64.c that are triggering stack protection. One is
__init, and the other takes no parameters and is not easily reachable
from userspace, so I don't think losing the stack canary on either of
those is a concern.
I don't see anything in paca.c triggering stack protection.
I don't think there's any evidence this is causing a bug for us, so I'll
plan to put this in next for v5.11.
cheers
Powered by blists - more mailing lists