From: "H. Peter Anvin" <hpa@zytor.com>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Alistair Strachan <astrachan@google.com>,
Manoj Gupta <manojgupta@google.com>,
Matthias Kaehlcke <mka@google.com>,
Greg Hackmann <ghackmann@google.com>,
sedat.dilek@gmail.com, tstellar@redhat.com,
LKML <linux-kernel@vger.kernel.org>,
Kees Cook <keescook@google.com>
Subject: Re: [clang] stack protector and f1f029c7bf
Date: Thu, 24 May 2018 15:05:53 -0700 [thread overview]
Message-ID: <dd1626ae-114f-3817-c8b2-f845e079bfc6@zytor.com> (raw)
In-Reply-To: <CAKwvOdnLt5qr_5ah86qdsocTxUbo_3X1y3PPRp1EZwt=__NxnA@mail.gmail.com>
On 05/24/18 13:26, Nick Desaulniers wrote:
>
> Considering the bigger picture is why we have this thread going. You have
> much more context about the kernel than I or the llvm maintainers do. We
> can't consider the bigger picture until we ask.
>
And this is correct. However, *every* LLVM request we get seem to be of
the form "if you apply this patch it will patch over one particular
instance of a problem with the kernel-LLVM."
There are two problems with that:
1. It focuses narrowly on an issue, which might (and more than a handful
of times have) mask much more fundamental, serious bugs, in both the
kernel and LLVM.
2. It makes it sound like an LLVM problem that wants to be hacked in the
kernel. More than a handful of times that is exactly what they have
been.
Look how many fundamental issues we have uncovered from this simple
issue, which would have gotten completely lost had we just applied this
patch.
>> Issue 1: Fundamentally,
>
> Fundamentally, the Linux kernel should not rely on GCC's heuristics for
> adding or not adding a stack protector to functions with custom calling
> conventions that are not marked in any way to let the compiler know.
This is true, although it is actually NOT the fundamental issue (see
below) but you also deleted the exact LLVM problem that I pointed out:
COMPILER AR: "=rm" should NEVER generate worse code than "=r". That is
unequivocally a compiler bug.
The other problem here is that omitting the stack canary is really not
the right thing to do, either. The right thing to do is to add a
mechanism for the compiler to know to reserve some number of stack
slots. Ideally this should work even if a function includes an inline
function or macro that contains the actual inline assembly.
COMPILER AR: Add a mechanism for the compiler to know that inline
assembly needs a certain amount of slack stack space. In the ideal
universe, this should ALSO mean the compiler offsets all "m" references
that contain references to the stack pointer.
KERNEL AR: Add those annotations to all cases of inline assembly that
modifies the stack pointer.
>> You are claiming it doesn't buy us anything, but you are only looking at
> the paravirt case which is kind of "special" (in the short bus kind of way),
>
> That's fair. Is another possible solution to have paravirt maybe not use
> native_save_fl() then, but its own non-static-inline-without-m-constraint
> implementation?
KERNEL AR: change native_save_fl() to an extern inline with an assembly
out-of-line implementation, to satisfy the paravirt requirement that no
GPRs other than %rax are clobbered.
>> Issue 3: Let's face it, reading and writing the flags should be builtins,
> exactly because it has to do stack operations, which really means the
> compiler should be involved.
>
> I'm happy to propose that as a feature request to llvm+gcc.
Being discussed elsewhere, of course.
-hpa
next prev parent reply other threads:[~2018-05-24 22:05 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-23 22:08 Nick Desaulniers
2018-05-24 10:33 ` Sedat Dilek
2018-05-24 18:12 ` Nick Desaulniers
2018-05-24 18:19 ` hpa
2018-05-24 18:24 ` Nick Desaulniers
2018-05-24 18:48 ` Alistair Strachan
2018-05-24 19:49 ` Tom Stellard
2018-05-24 21:33 ` hpa
2018-05-24 18:59 ` hpa
2018-05-24 20:26 ` Nick Desaulniers
2018-05-24 20:52 ` Nick Desaulniers
2018-05-24 21:12 ` Nick Desaulniers
2018-05-24 21:27 ` Nick Desaulniers
2018-05-24 21:56 ` H. Peter Anvin
2018-05-24 21:49 ` H. Peter Anvin
2018-05-24 21:38 ` hpa
2018-05-24 22:05 ` H. Peter Anvin [this message]
2018-05-24 22:31 ` Nick Desaulniers
2018-05-24 22:43 ` hpa
2018-05-25 16:27 ` Nick Desaulniers
2018-05-25 16:32 ` hpa
2018-05-25 16:46 ` Nick Desaulniers
2018-05-25 16:53 ` hpa
2018-05-25 17:31 ` Nick Desaulniers
2018-05-25 17:35 ` Tom Stellard
2018-05-25 17:49 ` Nick Desaulniers
2018-05-25 17:57 ` hpa
2018-05-25 17:59 ` Nick Desaulniers
2018-05-25 17:56 ` hpa
2018-05-25 20:36 ` Nick Desaulniers
2018-05-25 21:06 ` H. Peter Anvin
2018-05-25 22:38 ` Nick Desaulniers
2018-05-31 6:50 ` Nick Desaulniers
2018-06-01 17:13 ` Nick Desaulniers
2018-05-25 16:34 ` hpa
2018-05-25 8:24 ` Sedat Dilek
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=dd1626ae-114f-3817-c8b2-f845e079bfc6@zytor.com \
--to=hpa@zytor.com \
--cc=astrachan@google.com \
--cc=ghackmann@google.com \
--cc=keescook@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=manojgupta@google.com \
--cc=mka@google.com \
--cc=ndesaulniers@google.com \
--cc=sedat.dilek@gmail.com \
--cc=tstellar@redhat.com \
/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
all inboxes | Powered by JetHome®