Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp905932imm; Wed, 19 Sep 2018 08:45:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZLTA3dGj6KeX61zRPb6kNBGLcNHpjvcFIafCnQDbH2+tanwCzez5dbGXD18quaztozv/JX X-Received: by 2002:a62:51c6:: with SMTP id f189-v6mr36933964pfb.7.1537371918637; Wed, 19 Sep 2018 08:45:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537371918; cv=none; d=google.com; s=arc-20160816; b=GUcw3/cT4eLLVkLy1mbF8NALO59Xw8puZtZDXJnmV/7sfqmIbJzdhPgOLmKnA8E7BY b6z6kJBMjP0UP5qpP+fIFHib0TwL9Z2yPjAdJlP4VqqPZVXtgp4yPhkI/D9FS0sBm7f7 vvzTzlieFfVwCDDQMlSiLD2VKyBoAP4J08TfmyhjopePO5+N4S9OPqAaRJcpb1/as5Uv Y+gydPmlg0DwaFxiLKTfdPD8aWI+TsZQyRxp9GJav9fszSwP9hhO7HKFzd9uSlqDqqj9 aHDgJ2iX+iqsTMlSRMZ38Y9J/egQbWOXSOZ8Vagm1YP20jWLdAjg815GS0lqkYDx+dh6 6J/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=VGWw9HuZ8iPcfWRq4OOcD5x0N4s4FQYplacHpVzd58U=; b=LmX9UmDv8gerA4U1ECUBDaOQfvIlV1F+ICwe33YhMmePt7jHCW4janQYawBH00Zofl mUBMEJpGtebPj80VF6UL0p8ojiz26TrCK9zQ7HM3FdvFZXcNvkWz747LO5zJ3+cnU6+c lX1VXiOEm08leomne7I/BsBTM+5N4eJ371hkUs+OYvLOpkUCvOBWXcv5DAcikwtbWUFw 8wrGghTopq4ctWW1Nk1BaZN2atx+ct48QnLV1r/64leKXHs21S/ZkILn1FvgL0Mi+3y/ xaTzvaavwEm50wRyukwjPyOdJv6fYuqvWJv4HKKz6BZ9OLCU3WW6tFwSmYlles6tQ39u NWkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="p/HMv4PL"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s12-v6si22603336plr.120.2018.09.19.08.45.03; Wed, 19 Sep 2018 08:45:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="p/HMv4PL"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732581AbeISVVv (ORCPT + 99 others); Wed, 19 Sep 2018 17:21:51 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:41374 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732294AbeISVVv (ORCPT ); Wed, 19 Sep 2018 17:21:51 -0400 Received: by mail-qt0-f195.google.com with SMTP id t39-v6so5501953qtc.8 for ; Wed, 19 Sep 2018 08:43:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VGWw9HuZ8iPcfWRq4OOcD5x0N4s4FQYplacHpVzd58U=; b=p/HMv4PLv2313a4WuGzZcCwffTmu9cV4Y4PvJ0qHeL4qyBEEeJxKscqxzN7WPUWRdu GdNFzuBzqDCgNNOFEJr3LbarvdkpJ6+572TFRQKl4MW3N9SX+BRNHUp2McisOBUOx9pJ UXVDWeinLHDktYGJ0skAW0F2DWZymHLgiEmXvx4/kgjFD7LUc7VQ0vER/bPgwNkF+VA1 uZ/iV9tOqamUPqpRgFFhSBMn5eOG3d8ulTu3xxT3Le7UGEZMna0xgSZ8PsQMDAxN9UUS rdsDCuCaW+hoS9nOk2U/7/cpPoAiYF49Dz9RNbo/q5i+yvvLC8Jp4uY8VHWnc0AxAtch WHhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VGWw9HuZ8iPcfWRq4OOcD5x0N4s4FQYplacHpVzd58U=; b=oznlZBspFMyDDbZg8yPcbJYpEpA2A7yop78XOOK/ISqEFs18N32jrOdBj5h9bZ6COa Pzom6Nl3ofQBaGyVWHRahP+N+nTFhf0Oq/hAyPVkFxAjpuCK+UmbI9H/9gUwQILxz8Gt +Qc3sjC2G1GMT5PDb/6dA1unY1loGdEKrR/UIentVu8hYvBVXE3zey3y4rZsCO5R/V9r dwGBahIbagXiRqZRoWnceA62qjxRwndD2DjMlqTGVdFgjF9sc3v81fc0MtFWZT2fdmDz 0748PBlRF7phBDMZfNBQPJqT+CTyWt+ovagQbDH9NYQjqphEX/6NuuWS06s8Rlk/L7Ny bENw== X-Gm-Message-State: APzg51Dd/NuCVgKHSjBeA/9jCbblXv8DbaBdrbSppaqJH1NNts+AdRww hkbDKFWuPzJ6mK9sK2uUOVI3vtmJa/37M8MbDZjq X-Received: by 2002:aed:26e7:: with SMTP id q94-v6mr25426949qtd.37.1537371799009; Wed, 19 Sep 2018 08:43:19 -0700 (PDT) MIME-Version: 1.0 References: <20180820212556.GC2230@char.us.oracle.com> <1534801939.10027.24.camel@amazon.co.uk> <20180919010337.GC8537@350D> In-Reply-To: <20180919010337.GC8537@350D> From: Jonathan Adams Date: Wed, 19 Sep 2018 08:43:07 -0700 Message-ID: Subject: Re: Redoing eXclusive Page Frame Ownership (XPFO) with isolated CPUs in mind (for KVM to isolate its guests per CPU) To: bsingharora@gmail.com Cc: dwmw@amazon.co.uk, torvalds@linux-foundation.org, konrad.wilk@oracle.com, deepa.srinivasan@oracle.com, Jim Mattson , andrew.cooper3@citrix.com, linux-kernel@vger.kernel.org, boris.ostrovsky@oracle.com, linux-mm@kvack.org, tglx@linutronix.de, joao.m.martins@oracle.com, pradeep.vincent@oracle.com, ak@linux.intel.com, khalid.aziz@oracle.com, kanth.ghatraju@oracle.com, liran.alon@oracle.com, keescook@google.com, jsteckli@os.inf.tu-dresden.de, kernel-hardening@lists.openwall.com, chris.hyser@oracle.com, tyhicks@canonical.com, john.haxby@oracle.com, jcm@redhat.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (apologies again; resending due to formatting issues) On Tue, Sep 18, 2018 at 6:03 PM Balbir Singh wrote: > > On Mon, Aug 20, 2018 at 09:52:19PM +0000, Woodhouse, David wrote: > > On Mon, 2018-08-20 at 14:48 -0700, Linus Torvalds wrote: > > > > > > Of course, after the long (and entirely unrelated) discussion about > > > the TLB flushing bug we had, I'm starting to worry about my own > > > competence, and maybe I'm missing something really fundamental, and > > > the XPFO patches do something else than what I think they do, or my > > > "hey, let's use our Meltdown code" idea has some fundamental weakness > > > that I'm missing. > > > > The interesting part is taking the user (and other) pages out of the > > kernel's 1:1 physmap. > > > > It's the *kernel* we don't want being able to access those pages, > > because of the multitude of unfixable cache load gadgets. > > I am missing why we need this since the kernel can't access > (SMAP) unless we go through to the copy/to/from interface > or execute any of the user pages. Is it because of the dependency > on the availability of those features? > SMAP protects against kernel accesses to non-PRIV (i.e. userspace) mappings, but that isn't relevant to what's being discussed here. Davis is talking about the kernel Direct Map, which is a PRIV (i.e. kernel) mapping of all physical memory on the system, at VA = (base + PA). Since this mapping exists for all physical addresses, speculative load gadgets (and the processor's prefetch mechanism, etc.) can load arbitrary data even if it is only otherwise mapped into user space. XPFO fixes this by unmapping the Direct Map translations when the page is allocated as a user page. The mapping is only restored: 1. temporarily if the kernel needs direct access to the page (i.e. to zero it, access it from a device driver, etc), 2. when the page is freed And in so doing, significantly reduces the amount of non-kernel data vulnerable to speculative execution attacks against the kernel. (and reduces what data can be loaded into the L1 data cache while in kernel mode, to be peeked at by the recent L1 Terminal Fault vulnerability). Does that make sense? Cheers, - jonathan