[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdnq-H2M=psJMxo7k7HiEvZVY+z+4+geONwNZdBC9VmhvQ@mail.gmail.com>
Date: Fri, 25 May 2018 10:49:28 -0700
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: tstellar@...hat.com
Cc: hpa@...or.com, Alistair Strachan <astrachan@...gle.com>,
Manoj Gupta <manojgupta@...gle.com>,
Matthias Kaehlcke <mka@...gle.com>,
Greg Hackmann <ghackmann@...gle.com>, sedat.dilek@...il.com,
LKML <linux-kernel@...r.kernel.org>,
Kees Cook <keescook@...gle.com>
Subject: Re: [clang] stack protector and f1f029c7bf
On Fri, May 25, 2018 at 10:35 AM Tom Stellard <tstellar@...hat.com> wrote:
> On 05/25/2018 10:31 AM, Nick Desaulniers wrote:
> > On Fri, May 25, 2018 at 9:53 AM <hpa@...or.com> wrote:
> >> On May 25, 2018 9:46:42 AM PDT, Nick Desaulniers <
ndesaulniers@...gle.com>
> > wrote:
> >>> On Fri, May 25, 2018 at 9:33 AM <hpa@...or.com> wrote:
> >>>> On May 25, 2018 9:27:40 AM PDT, Nick Desaulniers
> >>> <ndesaulniers@...gle.com> wrote:
> >>> When you say
> >>>
> >>>> It still should be available as as inline, however, but now "extern
> >>> inline".
> >>>
> >>> Am I understanding correctly that native_save_fl should be inlined
into
> >>> all
> >>> call sites (modulo the problematic pv_irq_ops.save_fl case)? Because
> >>> for
> >>> these two assembly implementations, it's not, but maybe there's
> >>> something
> >>> missing in my implementation?
> >
> >> Yes, that's what "extern inline" means. Maybe it needs a must inline
> > annotation, but that's really messed up.
> >
> What about doing something like suggested here:
> https://bugs.llvm.org/show_bug.cgi?id=37512#c17
> This would keep the definition in C and make it easier for compilers
> to inline.
The GCC docs for __attribute__((naked)) seem to imply this is a machine
specific constraint (of which x86 is not listed):
https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Function-Attributes.html
But let's try with source:
https://godbolt.org/g/aJ4gZB
Clang errors:
<source>:3:3: error: non-ASM statement in naked function is not supported
unsigned long flags;
^
Is it valid to use assembly to place the results in %rax and mark the c
function somehow?
gcc doesn't support this attribute until 4.9 (but we can add a feature test
for attributes with gcc (unlike builtins)), but warns that:
warning: ‘naked’ attribute directive ignored [-Wattributes]
gcc 8.1 and trunk inserts a `ud2` instruction (what?!) (let me see if I can
repro outside of godbolt, and will file a bug report).
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists