linux-toolchains.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	linux-toolchains@vger.kernel.org,
	clang-built-linux <clang-built-linux@googlegroups.com>,
	"Jose E. Marchesi" <jemarch@gnu.org>,
	Kees Cook <keescook@chromium.org>,
	Florian Weimer <fweimer@redhat.com>,
	Christian Brauner <christian.brauner@canonical.com>,
	nick.alcock@oracle.com,
	Segher Boessenkool <segher@kernel.crashing.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Will Deacon <will@kernel.org>
Subject: Re: Plumbers CF MCs
Date: Wed, 24 Mar 2021 09:15:03 +0100	[thread overview]
Message-ID: <YFr1B18vJde2Q+p5@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20210323203612.02a5b29d@oasis.local.home>

On Tue, Mar 23, 2021 at 08:36:12PM -0400, Steven Rostedt wrote:
> On Tue, 23 Mar 2021 23:12:46 +0100
> Peter Zijlstra <peterz@infradead.org> wrote:
> 
> > On Tue, Mar 23, 2021 at 08:53:58PM +0100, Peter Zijlstra wrote:
> > 
> > > Another utterly disguisting option is to align all CALL instructions on
> > > 8 bytes and have it followed by 3 INT3s to make it 8 bytes long. Then
> > > have every function prologue round up the return address. This should
> > > work with tail-call optimizations because the round-up is NOP when
> > > repeated. The obvious down-side is that it will utterly wreck the RSB  
> > 
> > Slightly less horrible: "CALL func; INT3" + "INC (%RSP); RET; INT3".
> > It still completely wrecks RSB, but isn't nearly as wasteful.
> 
> I'm confused. Why is speculation after a CALL dangerous? That code will
> be executed on the return of the call anyway. That is, it's not
> speculating something that wont execute in the future, whereas code
> after RET and JMP wont be executed.

Like I just wrote to Andrew; it mostly isn't going to be. But there will
be cases where running the code after, with the register contents from
before, will get you a nice speculation gadget.

The big problem is, like with Spectre-v1 compiler mitigations,
recognising when it is and isn't a problem. Mostly compilers tend to
take the safe option (understandably) and we end up with an incredible
amount of LFENCE instructions and performance will suck.

For SLS at least the CALL+LFENCE pattern is trivial enough to recognise
and we can patch it out at runtime, with the only side effect being
code bloat and I$ fail. That same isn't true for Spectre-v1 mitigations,
where LFENCEs are emitted at less obviously recognised places.

  reply	other threads:[~2021-03-24  8:16 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22 20:23 Plumbers CF MCs Nick Desaulniers
2021-03-22 20:39 ` Jose E. Marchesi
2021-03-31 19:34   ` Elena Zannoni
2021-03-31 20:36     ` Nick Desaulniers
2021-04-01  7:59       ` Jose E. Marchesi
2021-04-01 20:01         ` Nick Desaulniers
2021-04-01 13:29       ` Steven Rostedt
2021-04-01 13:31         ` Steven Rostedt
2021-04-01 13:49         ` Elena Zannoni
2021-04-01 15:11           ` Miguel Ojeda
2021-04-01 20:11           ` Nick Desaulniers
2021-04-01 13:25     ` Steven Rostedt
2021-04-01 13:25       ` Steven Rostedt
2021-03-23  8:35 ` Peter Zijlstra
2021-03-23  8:45   ` Peter Zijlstra
2021-03-23 19:29   ` Andrew Cooper
2021-03-23 19:53     ` Peter Zijlstra
2021-03-23 22:12       ` Peter Zijlstra
2021-03-24  0:36         ` Steven Rostedt
2021-03-24  8:15           ` Peter Zijlstra [this message]
2021-03-23 22:23       ` Andrew Cooper
2021-03-24  8:08         ` Peter Zijlstra
2021-03-24 11:30           ` Andrew Cooper
2021-04-02 12:40       ` Segher Boessenkool
2021-03-23 22:26     ` Nick Desaulniers
2021-03-24  7:52       ` Peter Zijlstra
2021-03-24  8:47   ` Christian Brauner
2021-03-30 14:13   ` Will Deacon
2021-04-01  7:17     ` Kees Cook
2021-04-02 12:33   ` Segher Boessenkool

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=YFr1B18vJde2Q+p5@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=christian.brauner@canonical.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=fweimer@redhat.com \
    --cc=jemarch@gnu.org \
    --cc=jpoimboe@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-toolchains@vger.kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nick.alcock@oracle.com \
    --cc=rostedt@goodmis.org \
    --cc=segher@kernel.crashing.org \
    --cc=will@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;
as well as URLs for NNTP newsgroup(s).