Return-path: Received: from mail-pg0-x234.google.com ([2607:f8b0:400e:c05::234]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1fC9QU-0007rD-3Z for speck@linutronix.de; Fri, 27 Apr 2018 21:53:02 +0200 Received: by mail-pg0-x234.google.com with SMTP id a13-v6so2298686pgu.4 for ; Fri, 27 Apr 2018 12:53:02 -0700 (PDT) Received: from i7.lan (c-73-11-52-149.hsd1.or.comcast.net. [73.11.52.149]) by smtp.gmail.com with ESMTPSA id z127sm3675200pfb.72.2018.04.27.12.52.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Apr 2018 12:52:54 -0700 (PDT) Sender: Linus Torvalds Date: Fri, 27 Apr 2018 12:52:54 -0700 (PDT) From: Linus Torvalds Subject: [MODERATED] Re: [PATCH v2] Linux Patch 1/1 In-Reply-To: <2de93c45-9bcc-136d-3534-03d05bd6b660@redhat.com> Message-ID: References: <92c45587-5eb3-2421-6fc1-42e74a715e30@linux.intel.com> <20180427164743.GA14180@pd.tnic> <6e2b14fc-3bf6-071d-6ce2-e518f2c4f069@redhat.com> <20180427173221.GB14180@pd.tnic> <20180427180944.GD75137@tassilo.jf.intel.com> <2de93c45-9bcc-136d-3534-03d05bd6b660@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Fri, 27 Apr 2018, speck for Jon Masters wrote: > > It /might/ be an issue for the kernel stack. This is the fear many of us > have. Honestly, the kernel stack worry would be the *reverse* of the store buffer bypass. The actual cache contents should be safe (meltdown), but a a user space load that hits in the store buffer of a kernel store might bypass the TLB checks _entirely_. So that would be a store buffer *HIT*, not a "speculatively do a load that later turns out _should_ have hit the store buffer". That would be an architectural flaw, but one that should be fairly easy to mitigate ("just add a barrier before the return to user space, and curse the incompetence of hardware designers"). > However, we do an lfence on entry to the kernel I wouldn't worry about kernel _entry_, since any data the kernel reads is by definition not a security issue. We have lots of cases where the kernel can get stale data because of speculation. That's not in the least new. Examples of "kernel gets stale user space data" are things like takin ga fault on an instruction that has in the meantime been rewritten (due to incomplete I$ coherency). The kernel sees a fault from something that no longer even exists. So it's kernel exit I'd worry about, where a kernel store that is (still) in the store buffers can be incorrectly seen by user space because the store buffer load forwarding doesn't do any permission checking at all. I'm assuming nobody has _that_ bug. But it might be worth asking around. Linus PS. The real kernel worry wrt the store buffer bypass is obviously ebpf, not kernel entry/exit.