public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Singh, Balbir" <sblbir@amazon.com>
To: "Herrenschmidt, Benjamin" <benh@amazon.com>,
	"luto@amacapital.net" <luto@amacapital.net>
Cc: "tglx@linutronix.de" <tglx@linutronix.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"keescook@chromium.org" <keescook@chromium.org>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [RFC PATCH] arch/x86: Optionally flush L1D on context switch
Date: Mon, 23 Mar 2020 00:12:18 +0000	[thread overview]
Message-ID: <f5f6bca2ccbbd3d5a82209a02ebf64834d1fe8fb.camel@amazon.com> (raw)
In-Reply-To: <A38682A4-62B2-4849-ADEA-196DFF4D36C9@amacapital.net>

On Sun, 2020-03-22 at 08:10 -0700, Andy Lutomirski wrote:
> 
> > I still think flushing the "high value" process L1D on switch_mm out is
> > the way to go here...
> 
> Let me try to understand the issue. There is some high-value data, and that
> data is owned by a high-value process. At some point, the data ends up in
> L1D.  Later in, evil code runs and may attempt to exfiltrate  that data from
> L1D using a side channel. (The evil code is not necessarily in a malicious
> process context. It could be kernel code targeted by LVI or similar. It
> could be ordinary code that happens to contain a side channel gadget by
> accident.)
> 
> So the idea is to flush L1D after manipulating high-value data and before
> running evil code.
> 
> The nasty part here is that we don’t have a good handle on when L1D is
> filled and when the evil code runs. If the evil code is untrusted process
> userspace and the fill is an interrupt, then switch_mm is useless and we
> want to flush on kernel exit instead. If the fill and evil code are both
> userspace, then switch_mm is probably the right choice, but
> prepare_exit_from_usermode works too. If SMT is on, we lose no matter
> what.  If the evil code is in kernel context, then it’s not clear what to
> do. If the fill and the evil code are both in kernel threads (hi, io_uring),
> then I’m not at all sure what to do.
> 
> In summary, kernel exit seems stronger, but the right answer isn’t so clear.
> 
> We could do an optimized variant where we flush at kernel exit but we
> *decide* to flush in switch_mm.

I think the key question in the LVI case would be, is it possible to do an LVI
in a kernel context? If the answer is no, switch_mm() is sufficient, but for
now these patches focus on flushing L1D on task exit, we could add the use
case for LVI (which is called out)

Balbir Singh.

  parent reply	other threads:[~2020-03-23  0:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-13 22:04 [RFC PATCH] arch/x86: Optionally flush L1D on context switch Balbir Singh
2020-03-18 23:14 ` Kees Cook
2020-03-20  1:35   ` Singh, Balbir
2020-03-19  0:38 ` Thomas Gleixner
2020-03-20  1:37   ` Singh, Balbir
2020-03-20 11:49     ` Thomas Gleixner
2020-03-21  1:42       ` Singh, Balbir
2020-03-21 10:05         ` Thomas Gleixner
2020-03-22  5:10           ` Herrenschmidt, Benjamin
2020-03-23  0:37           ` Singh, Balbir
2020-03-22  5:08       ` Herrenschmidt, Benjamin
2020-03-22 15:10         ` Andy Lutomirski
2020-03-22 23:17           ` Herrenschmidt, Benjamin
2020-03-23  0:12           ` Singh, Balbir [this message]
2020-03-22  5:01   ` Herrenschmidt, Benjamin

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=f5f6bca2ccbbd3d5a82209a02ebf64834d1fe8fb.camel@amazon.com \
    --to=sblbir@amazon.com \
    --cc=benh@amazon.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --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