From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Dan Williams <dan.j.williams@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Andi Kleen <ak@linux.intel.com>, X86 ML <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH v2 1/3] x86/entry: Clear extra registers beyond syscall arguments for 64bit kernels
Date: Mon, 5 Feb 2018 11:48:29 -0600 [thread overview]
Message-ID: <20180205174829.d7rflcxigbx2snra@treble> (raw)
In-Reply-To: <CALCETrXs=PUu5TtEnCYVh3n180tH0NPm9DE0pd7ZdneAJBcy1g@mail.gmail.com>
On Mon, Feb 05, 2018 at 05:31:39PM +0000, Andy Lutomirski wrote:
> On Mon, Feb 5, 2018 at 5:26 PM, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> > On Mon, Feb 05, 2018 at 04:37:26PM +0000, Andy Lutomirski wrote:
> >> On Mon, Feb 5, 2018 at 4:30 PM, Ingo Molnar <mingo@kernel.org> wrote:
> >> >
> >> > * Andy Lutomirski <luto@amacapital.net> wrote:
> >> >
> >> >>
> >> >>
> >> >> > On Feb 5, 2018, at 3:42 AM, Ingo Molnar <mingo@kernel.org> wrote:
> >> >> >
> >> >> >
> >> >> > * Dan Williams <dan.j.williams@intel.com> wrote:
> >> >> >
> >> >> >> + /*
> >> >> >> + * Sanitize extra registers of values that a speculation attack
> >> >> >> + * might want to exploit. In the CONFIG_FRAME_POINTER=y case,
> >> >> >> + * the expectation is that %ebp will be clobbered before it
> >> >> >> + * could be used.
> >> >> >> + */
> >> >> >> + .macro CLEAR_EXTRA_REGS_NOSPEC
> >> >> >> + xorq %r15, %r15
> >> >> >> + xorq %r14, %r14
> >> >> >> + xorq %r13, %r13
> >> >> >> + xorq %r12, %r12
> >> >> >> + xorl %ebx, %ebx
> >> >> >> +#ifndef CONFIG_FRAME_POINTER
> >> >> >> + xorl %ebp, %ebp
> >> >> >> +#endif
> >> >> >> + .endm
> >> >> >
> >> >> > Yeah, so this series look pretty good to me, but there's one small detail: I think
> >> >> > RBP should be cleared unconditionally here, even in the CONFIG_FRAME_POINTERS=y
> >> >> > case, because:
> >> >>
> >> >> ENCODE_FRAME_POINTER should take care of rbp, though.
> >> >
> >> > AFAICS there's various entry paths where it's not used I think: for example the
> >> > compat system calls in entry_64_compat.S don't seem to encode RBP in such a
> >> > fashion (unless I missed some macro side effect).
> >>
> >> Then that's a separate bug that should be fixed. Josh?
> >
> > We don't encode the frame pointer on syscalls, because "fast path"
> > (though that's obviously no longer a consideration).
>
> Should we start encoding the frame pointer?
Perhaps, but I should clarify it's not a bug. For syscalls, we instead
just standardized the location of the last stack frame. But that's a
bit fragile and I was never too happy with it.
Encoding the frame pointer would be a lot more straightforward, though
we'd still need to figure out a way to detect the "end" of the stack for
kthreads. We could probably encode that information as well: "here's
the end, but there are no pt_regs". Could just be an "encoded" NULL.
--
Josh
next prev parent reply other threads:[~2018-02-05 17:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-04 17:43 [PATCH v2 0/3] x86/entry: Clear registers to sanitize speculative usages Dan Williams
2018-02-04 17:44 ` [PATCH v2 1/3] x86/entry: Clear extra registers beyond syscall arguments for 64bit kernels Dan Williams
2018-02-05 11:42 ` Ingo Molnar
2018-02-05 15:37 ` Andy Lutomirski
2018-02-05 16:30 ` Ingo Molnar
2018-02-05 16:37 ` Andy Lutomirski
2018-02-05 17:26 ` Josh Poimboeuf
2018-02-05 17:31 ` Andy Lutomirski
2018-02-05 17:48 ` Josh Poimboeuf [this message]
2018-02-05 15:58 ` Andi Kleen
2018-02-06 7:19 ` Ingo Molnar
2018-02-05 11:58 ` Ingo Molnar
2018-02-05 21:33 ` Dan Williams
2018-02-05 21:58 ` Linus Torvalds
2018-02-05 22:10 ` Andy Lutomirski
2018-02-05 22:19 ` Dan Williams
2018-02-05 22:22 ` Linus Torvalds
2018-02-05 22:25 ` Linus Torvalds
2018-02-04 17:44 ` [PATCH v2 2/3] x86/entry: Clear registers for 64bit exceptions/interrupts Dan Williams
2018-02-04 17:44 ` [PATCH v2 3/3] x86/entry: Clear registers for compat syscalls Dan Williams
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=20180205174829.d7rflcxigbx2snra@treble \
--to=jpoimboe@redhat.com \
--cc=ak@linux.intel.com \
--cc=dan.j.williams@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--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
all inboxes | Powered by JetHome®