Return-path: Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1fERkb-00026U-L6 for speck@linutronix.de; Fri, 04 May 2018 05:51:18 +0200 Received: by mail-pf0-x22d.google.com with SMTP id p12so16368464pff.13 for ; Thu, 03 May 2018 20:51:17 -0700 (PDT) Received: from xps13.linux-foundation.org ([2605:e000:d602:1400:2d65:9003:2c6c:b4fa]) by smtp.gmail.com with ESMTPSA id z62sm34372645pff.57.2018.05.03.20.51.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 May 2018 20:51:09 -0700 (PDT) Sender: Linus Torvalds Date: Thu, 3 May 2018 17:51:07 -1000 (HST) From: Linus Torvalds Subject: [MODERATED] Re: [PATCH v2] Linux Patch 1/1 In-Reply-To: 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 Thu, 3 May 2018, speck for Jiri Kosina wrote: > > > Honestly, the store buffer bypass is really really hard to use to attack > > the kernel exactly because you need that third memory access to perturb > > the side channel, and the first access has to be a store with the right > > setup so that the second access loads the wrong data, and the wrong data > > is the interesting one (not the right one from the store). > > So even if there really are no such gadgets / constructs anywhere in the > kernel, they can be of course created through BPF. No, not really. There is no "of course". It's not clear that such a gadget can be constructed at all with bpf. We should *not* say "of course you can construct that" without having any kind of real data on that. The thing is, to construct that, you really have to construct: - a store to the same address that you do a subsequent load from This part is probably easyish. BUT: - you have to use a different base pointer for it, which suddenly means that it's not the obvious case of a stack spill "let's store to the stack and the load the value back", because that generally uses the same base pointer unless your code generation is complete garbage. So now you have one big wrinkle already. But the *really* big wrinkle is that you also have to have interesting data that the store that was bypassed was actually hiding. But let's assume you have that store-load pair, and let's assume you actually can load some interesting data that the first store overwrote. Now you need to do the second indirect load to act as the side channel for the cache. So it's not trivial to generate in the first place, but then you need to *run* this gadget too. Which shouldn't be possible in the first place, since you now need bascially the Spectre v1 to execute that arbitrary code. And the thing is, if you need spectre v1 to execute it, why go through all that complexity? Just do the original spectre thing to begin with. No. To be practically exploitable, you need to be able to just generate the code and run it directly. But again, I'm assuming just the *regular* spectre is easier to just exploit if you can do that. So what we should look at is "can you make ebpf easily generate that "store followed by load from same address with a different base register, and can you run it as non-root". And I haven't seen anybody actually try to look into that. Have the ebpf people been involved on this issue at all? Linus