Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp67177pxb; Sat, 9 Oct 2021 13:41:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQQwK5aPxXzYx1DqjIOy5WUFTKh0u/R4L4a4Fk8djVDoU6w+NdyQu/wtmyevEZIZX/M7cB X-Received: by 2002:a62:4e81:0:b0:44c:85ec:96ca with SMTP id c123-20020a624e81000000b0044c85ec96camr17416855pfb.58.1633812072044; Sat, 09 Oct 2021 13:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633812072; cv=none; d=google.com; s=arc-20160816; b=KltetDog/ULmrcVM13YwPASeui9lmbRQE/2X+ckALHlxZl+lbto+uHR4XXTc2XpAEd 7Y9PlL91sUdH5vs629Z8lgew2fCqc/sW6HCTZFFRAASHsrJRUF+Rcpa1pX1Vla+R2q0b d00RPXwLgSZQ0JFoWhwUF0XjbFFYKWhSBVvX93bNBw0Cptipwd6P/gnXBQlSj0RaLhpT 2roHSVBzgQ7rgIzPlUNRhavfGOR9uci7uLXzrhg0OngpUF/Xm+veEwbt8S5In/rKCd37 a/O9z7z7F22YYnfrXzYwvdFSTd1oYX2IOwhMGKO+SebhNMCSfTsT2vAfNI0bU6Uo1DfY YIBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=PNkbI6CC4MPwch06xoRoPuOpZuZRykTcMawJcvuLIGc=; b=XOsDtOFoOfP+u1HQ5hCjAoYcuJxk/HHTevYo4rpO0tpzrjINL086EFNC3tdBu/IWWW KMVbJHea7PKaISOAZzY2Na9aocXcotwPymI0G/sz1eU/CvPkQR2hYYgI59zsUTvgIJBZ n877vXYAEWxqnXP5I5QU0siFKbfM8MwQqFSsC8MwPmAALjeKMIDdHBdzol49MpNRbUIE /q/rz62Y0cjo7HsXi3RgcEMakA4NokepTnZl1NqGggD7bP7opcyXDormLJZ+V1AkLEkP zWHDJhBYneiE612GgvK2NT14p77K9p5tyjW8KUMa2KiUNObMsXAXfmkuKBHgiLGfSNQA 77Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20210112.gappssmtp.com header.s=20210112 header.b=Muu3r0eH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n65si4177298pfd.158.2021.10.09.13.40.57; Sat, 09 Oct 2021 13:41:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20210112.gappssmtp.com header.s=20210112 header.b=Muu3r0eH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230342AbhJIUmI (ORCPT + 99 others); Sat, 9 Oct 2021 16:42:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230257AbhJIUmG (ORCPT ); Sat, 9 Oct 2021 16:42:06 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B646C061768 for ; Sat, 9 Oct 2021 13:40:09 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id np13so10135545pjb.4 for ; Sat, 09 Oct 2021 13:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PNkbI6CC4MPwch06xoRoPuOpZuZRykTcMawJcvuLIGc=; b=Muu3r0eHUqB/dNHg2SbcMZBR59fyebiqEBsvk6PezrQlxQGwEI1ZicQJ1XHU8yb+jR kHSIW8u2KEJn+hh/8bqD+oSUoLGTMzHi2MKjMWxijaluyFQ9X/HFL9QP8jG3kJvP1+yC MFrvKW7dOAqDY1UzAuwqQRxVpGtbg2xoYhxoIQminXJgv3DKYb4mwO0GqHZDYiNWBRPr zX9FmLpjC1P17blRe4cxwK4BawnSAcTVigJTMtvWGUVR4Krw0LhW/yHMyjDs7LwJths0 zTeiN6ZgCa7R3RDBLb9WPt7ZUqU0TGXpSpq1OOroQI9pRt1DcheHTMwoozKzKGHc51Jc ai5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PNkbI6CC4MPwch06xoRoPuOpZuZRykTcMawJcvuLIGc=; b=B4LONTOt6f2T0tivGp85nASxzqqGowu7DXF+Hy/WEOBFb2TMTOcYPxdIxVQH5sGpkp Q+aUL1ZLO4jDtYBygI663Ak16bVgTVAoEYnVr1ekwJNEJs8b8gsTi8Sa7pWtVjGLe+m/ c19Gj10O2cCoYtiS79cVgIwyW1JuNMToGy8yzsMWphQRgcp5VdmTGwQYnRJDuapp99i/ WjyTF9CIdpJ83WSlwsY4iTnPZIym147MXGN/Pe2riQ+bNIsvyYEZ1RQ1jPHAy+uqehOa voc6gU+eTFaQzBcClidbAtJ2fxl0rkW7NxysYkSBlLCufgsz/th5k+djH8GJjz7Cka+U HGVw== X-Gm-Message-State: AOAM531kZoeX9/VXnH4ufXtzldbGUin6Ndwbe3NRkK6sobxh4yI0hfVB 4kSKHmbrwoJHA+BZcjqwW0IbJQua3jn8opr2hOpv4w== X-Received: by 2002:a17:90a:d686:: with SMTP id x6mr20678375pju.8.1633812008773; Sat, 09 Oct 2021 13:40:08 -0700 (PDT) MIME-Version: 1.0 References: <20211009003711.1390019-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20211009003711.1390019-13-sathyanarayanan.kuppuswamy@linux.intel.com> <20211009053103-mutt-send-email-mst@kernel.org> In-Reply-To: <20211009053103-mutt-send-email-mst@kernel.org> From: Dan Williams Date: Sat, 9 Oct 2021 13:39:57 -0700 Message-ID: Subject: Re: [PATCH v5 12/16] PCI: Add pci_iomap_host_shared(), pci_iomap_host_shared_range() To: "Michael S. Tsirkin" Cc: Kuppuswamy Sathyanarayanan , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Andy Lutomirski , Bjorn Helgaas , Richard Henderson , Thomas Bogendoerfer , James E J Bottomley , Helge Deller , "David S . Miller" , Arnd Bergmann , Jonathan Corbet , Paolo Bonzini , David Hildenbrand , Andrea Arcangeli , Josh Poimboeuf , Peter H Anvin , Dave Hansen , Tony Luck , Andi Kleen , Kirill Shutemov , Sean Christopherson , Kuppuswamy Sathyanarayanan , X86 ML , Linux Kernel Mailing List , Linux PCI , linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-arch , Linux Doc Mailing List , virtualization@lists.linux-foundation.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 9, 2021 at 2:53 AM Michael S. Tsirkin wrote: > > On Fri, Oct 08, 2021 at 05:37:07PM -0700, Kuppuswamy Sathyanarayanan wrote: > > From: Andi Kleen > > > > For Confidential VM guests like TDX, the host is untrusted and hence > > the devices emulated by the host or any data coming from the host > > cannot be trusted. So the drivers that interact with the outside world > > have to be hardened by sharing memory with host on need basis > > with proper hardening fixes. > > > > For the PCI driver case, to share the memory with the host add > > pci_iomap_host_shared() and pci_iomap_host_shared_range() APIs. > > > > Signed-off-by: Andi Kleen > > Signed-off-by: Kuppuswamy Sathyanarayanan > > So I proposed to make all pci mappings shared, eliminating the need > to patch drivers. > > To which Andi replied > One problem with removing the ioremap opt-in is that > it's still possible for drivers to get at devices without going through probe. > > To which Greg replied: > https://lore.kernel.org/all/YVXBNJ431YIWwZdQ@kroah.com/ > If there are in-kernel PCI drivers that do not do this, they need to be > fixed today. > > Can you guys resolve the differences here? I agree with you and Greg here. If a driver is accessing hardware resources outside of the bind lifetime of one of the devices it supports, and in a way that neither modrobe-policy nor device-authorization -policy infrastructure can block, that sounds like a bug report. Fix those drivers instead of sprinkling ioremap_shared in select places and with unclear rules about when a driver is allowed to do "shared" mappings. Let the new device-authorization mechanism (with policy in userspace) be the central place where all of these driver "trust" issues are managed. > And once they are resolved, mention this in the commit log so > I don't get to re-read the series just to find out nothing > changed in this respect? > > I frankly do not believe we are anywhere near being able to harden > an arbitrary kernel config against attack. > How about creating a defconfig that makes sense for TDX then? > Anyone deviating from that better know what they are doing, > this API tweaking is just putting policy into the kernel ... Right, userspace authorization policy and select driver fixups seems to be the answer to the raised concerns.