Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 14 Aug 2018 09:53:33 -0000 Received: from mail.skyhub.de ([2a01:4f8:190:11c2::b:1457]) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fpVw8-0005Sw-I3 for speck@linutronix.de; Tue, 14 Aug 2018 11:48:24 +0200 Received: from mail.skyhub.de ([127.0.0.1]) by localhost (blast.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id CBon2imx1ERo for ; Tue, 14 Aug 2018 11:48:05 +0200 (CEST) Received: from canaan.localdomain (p50991abe.dip0.t-ipconnect.de [80.153.26.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 64EC21EC0118 for ; Tue, 14 Aug 2018 11:48:05 +0200 (CEST) Subject: [MODERATED] Re: Cache load gadgets References: <1533736415.3615.64.camel@infradead.org> <20180808145316.GX4238@tassilo.jf.intel.com> <20180808153429.quokqzwwvnripsdj@treble> <20180813151727.GA15539@char.us.oracle.com> <1534178427.2538.64.camel@infradead.org> <20180813192757.GA25361@agluck-desk> From: Julian Stecklina Message-ID: <74d17229-bb72-5d2b-7ea9-46402c0f0b07@alien8.de> Date: Tue, 14 Aug 2018 11:48:00 +0200 MIME-Version: 1.0 In-Reply-To: <20180813192757.GA25361@agluck-desk> Content-Type: multipart/mixed; boundary="vR1Ecdv8GM9nfNyaBt2StKP1gKoESGae1"; protected-headers="v1" To: speck@linutronix.de List-ID: This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156) --vR1Ecdv8GM9nfNyaBt2StKP1gKoESGae1 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Content-Language: en-US On 08/13/2018 09:27 PM, speck for Luck, Tony wrote: > On Mon, Aug 13, 2018 at 06:40:27PM +0200, speck for David Woodhouse wro= te: >> Even the gadget fixes are a band-aid. As Josh says, there are hundreds= >> of them. It's not massively feasible to close every gap, if this is >> what we consider the attack surface to be. >> >> I think we need to take a serious look at actually removing sensitive >> pages from the physical 1:1 map so that they *can't* be accessed. >> >> Maybe start with a way for kernel code to request an "otherwise >> unmapped" page, which would need to be explicitly mapped for each >> access (after ensuring that no potentially malicious guest is running)= =2E >> Or which could be mapped into a per-process address, in some cases >> (like a VMCS for a given vCPU). > Could we build on top of KPTI? I.e. on entry to the kernel we currentl= y > have nothing important mapped. If we added code to that to validate use= r > input (i.e. the "front-end" to system calls). If out of range values ar= e > found then we have a fast -EINVAL back to the user. If everything is OK= , > then we do the KPTI switch to the full kernel address space. > > ioctl would be a pain, but most other system calls would just require > refactoring into a front-end validity check and a back end that does > the real work. That's unfortunately not sufficient. You could still end up pulling arbitrary memory in the cache by misspeculating in the kernel. In the long term, fixing gadgets and making all input validation "speculation-safe" is a losing battle. The viable long term plan is to remove as many mappings from the global kernel address space as possible. Specifically, while being in the context of process A, memory of process B should not be visible in the kernel. If that's the case, no gadget can speculatively pull B's memory into the L1 cache. At the moment, this is not the case. The big problem is the 1:1 mapping of all physical memory. And after that, there is disk cache, userspace register state or vCPU state floating around in the kern= el. Julian --vR1Ecdv8GM9nfNyaBt2StKP1gKoESGae1--