From: Kristen C Accardi <kristen@linux.intel.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: Kernel Hardening <kernel-hardening@lists.openwall.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>, X86 ML <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86: entry: flush the cache if syscall error
Date: Thu, 11 Oct 2018 13:15:50 -0700 [thread overview]
Message-ID: <1539288950.3566.11.camel@linux.intel.com> (raw)
In-Reply-To: <CALCETrW5sNz-TO8w8e+7d1oD_CmnUX_txnBuKe2+wM7qFaK64A@mail.gmail.com>
On Thu, 2018-10-11 at 12:25 -0700, Andy Lutomirski wrote:
> On Thu, Oct 11, 2018 at 11:55 AM Kristen Carlson Accardi
> <kristen@linux.intel.com> wrote:
> >
> > This patch aims to make it harder to perform cache timing attacks
> > on data
> > left behind by system calls. If we have an error returned from a
> > syscall,
> > flush the L1 cache.
> >
> > It's important to note that this patch is not addressing any
> > specific
> > exploit, nor is it intended to be a complete defense against
> > anything.
> > It is intended to be a low cost way of eliminating some of side
> > effects
> > of a failed system call.
> >
> > A performance test using sysbench on one hyperthread and a script
> > which
> > attempts to repeatedly access files it does not have permission to
> > access
> > on the other hyperthread found no significant performance impact.
> >
> > +__visible inline void l1_cache_flush(struct pt_regs *regs)
> > +{
> > + if (IS_ENABLED(CONFIG_SYSCALL_FLUSH) &&
> > + static_cpu_has(X86_FEATURE_FLUSH_L1D)) {
> > + if (regs->ax == 0 || regs->ax == -EAGAIN ||
> > + regs->ax == -EEXIST || regs->ax == -ENOENT ||
> > + regs->ax == -EXDEV || regs->ax == -ETIMEDOUT ||
> > + regs->ax == -ENOTCONN || regs->ax ==
> > -EINPROGRESS)
> > + return;
> > +
> > + wrmsrl(MSR_IA32_FLUSH_CMD, L1D_FLUSH);
> > + }
> > +}
>
> Ugh.
>
> What exactly is this trying to protect against? And how many cycles
> should we expect L1D_FLUSH to take?
As I mentioned in the commit message, this is not addressing any
specific exploit. It is removing any side effects from a failed system
call in the L1 cache.
>
> ISTM that, if we have a situation where the L1D can be read by user
> code, we lose, via hyperthreading, successful syscalls, /dev/random,
> and may other vectors. This seems like a small mitigation at a
> rather
> large cost.
I pinned an evil task to one hyperthread that just caused L1 flushes by
issuing failed system calls. On the other hyperthread, I ran a
performance benchmark (sysbench). I did not see any difference between
the baseline and the kernel with the patch applied. Is there a more
appropriate test you'd be interested in seeing the results of? I'd be
happy to design a different test.
next prev parent reply other threads:[~2018-10-11 20:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-11 18:54 [PATCH] x86: entry: flush the cache if syscall error Kristen Carlson Accardi
2018-10-11 19:25 ` Andy Lutomirski
2018-10-11 20:15 ` Kristen C Accardi [this message]
2018-10-11 20:25 ` Alan Cox
2018-10-11 20:47 ` Andy Lutomirski
2018-10-12 9:20 ` Samuel Neves
2018-10-12 13:25 ` Jann Horn
2018-10-12 14:28 ` Samuel Neves
2018-10-11 20:48 ` Andy Lutomirski
2018-10-11 20:55 ` Kees Cook
2018-10-11 21:17 ` Andy Lutomirski
2018-10-11 22:11 ` Jann Horn
2018-10-12 14:25 ` Alan Cox
2018-10-12 14:43 ` Andy Lutomirski
2018-10-12 15:02 ` Alan Cox
2018-10-12 15:41 ` Jann Horn
2018-10-12 16:07 ` Andy Lutomirski
2018-10-11 21:23 ` Kristen C Accardi
2018-10-11 23:43 ` Thomas Gleixner
2018-10-11 21:42 ` Jann Horn
2018-10-11 23:15 ` Thomas Gleixner
2018-10-11 22:33 ` Thomas Gleixner
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=1539288950.3566.11.camel@linux.intel.com \
--to=kristen@linux.intel.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--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