Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp952426ybt; Wed, 1 Jul 2020 14:25:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyH3VypaITdpzsUZbZODzAuyubEo9y6BvfJFu0LF8seqBvw6PAgBG7QeFAY+JqAaWI4XrcT X-Received: by 2002:a17:906:3850:: with SMTP id w16mr23560675ejc.205.1593638705196; Wed, 01 Jul 2020 14:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593638705; cv=none; d=google.com; s=arc-20160816; b=cOVQYWSIUo/haePzj1GjEXPeZW/Idcy5tDTUp8HB4p75ZNQd4FzE6lRZGBJANmojke Jtdswb8qPK9Nmr0SZpOPOpwcJ+GgTFw5Sqo3zMaps8AhrypCiBTgoCDGKmBYUcLYH8Y1 bEJKTZH8H5HGbwgjrksWW1CtNt/NUr++qpfWJC+oTFbz4OBwrAY4Ym9MdDfwZgYKbp8T 0OKz619AmBJ/3OijHfAPnB6p+DdDzGJNQEgivXWn9lOW5MCHzxAnJChwwVAalsge5xUj NLjxcLLT9JNXUvyJpEPzmp4btUx0l0zzLhnc2YYr8vjsTcsAy+oJf6SCx+ELU9R/jd2/ UAaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=FG7bCrcbyqkkXqycM/jFYPtkgZIE8oYQr7mPIfYVOgM=; b=QZxe8Ro3uOtBNpVJnsk63cSIg8q1zEKjIZCnFyI9tj+65FHYnjwvQaLnvewZ8DBsiL zfa5GH/YODPURuIfLlO7dRRWzSlgThng32l/xDD/oDRkPz0T8WBab1hao+7ZlGdpVRCn 1On9IHSAZdIZ8x9nqoT261WCJukREzR1P6SppCQ7LITn62wYVIBUMWOXf36tpGrT8cmh JT20+cJ85e4YAq0pSy0A3dWicPThsUweZhM/ik4TPIYuHxPIT5Nryimu47QVfk0RB2I4 dYxKGkG3FIlElmrFJO7H9w34Ba+nWbgEG25R5In9QXCn13aYTipaCzTV2TsOU96exUvx PcpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=j1Z+d1i5; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si4330189ejw.207.2020.07.01.14.24.40; Wed, 01 Jul 2020 14:25:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@kernel.org header.s=default header.b=j1Z+d1i5; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbgGAVYk (ORCPT + 99 others); Wed, 1 Jul 2020 17:24:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:38580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725915AbgGAVYk (ORCPT ); Wed, 1 Jul 2020 17:24:40 -0400 Received: from localhost (mobile-166-175-191-139.mycingular.net [166.175.191.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B3C9B2085B; Wed, 1 Jul 2020 21:24:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593638679; bh=y7Tj7NAUhvu0M9VijaEG0Jdd9zOA89epyoyiU3TDZxM=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=j1Z+d1i5LcEvbJzOmf03DnZGUtej26H5zKgrH68wE1n1Gb5zYpaO77D08hZfYD3SA a/bPOI2iSGCNdUI9smIf6JON7/ej/h0E5t3Dvq2CQtJqTqVbtAZuiFzFGEV9N7PDqU kQHb7jW7OsaqMSAq9/65dw3B6Nwpfx4sdE3xXs/8= Date: Wed, 1 Jul 2020 16:24:37 -0500 From: Bjorn Helgaas To: Giovanni Cabiddu Cc: alex.williamson@redhat.com, herbert@gondor.apana.org.au, cohuck@redhat.com, nhorman@redhat.com, vdronov@redhat.com, bhelgaas@google.com, mark.a.chambers@intel.com, gordon.mcfadden@intel.com, ahsan.atta@intel.com, qat-linux@intel.com, kvm@vger.kernel.org, linux-crypto@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/5] vfio/pci: add device blocklist Message-ID: <20200701212437.GA3660694@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200701110302.75199-3-giovanni.cabiddu@intel.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Jul 01, 2020 at 12:02:59PM +0100, Giovanni Cabiddu wrote: > Add blocklist of devices that by default are not probed by vfio-pci. > Devices in this list may be susceptible to untrusted application, even > if the IOMMU is enabled. I can't quite parse this sentence. I think it means something about these devices being able to bypass an IOMMU or otherwise cause problems via DMA. It would be nice to know exactly what problem this is avoiding. I assume *all* applications are untrusted, right? The wording above makes it sound like there may be a class of trusted applications in addition to the untrusted ones. But I don't see anything like that in the patch. > To be accessed via vfio-pci, the user has to > explicitly disable the blocklist. > > The blocklist can be disabled via the module parameter disable_blocklist. > > Signed-off-by: Giovanni Cabiddu > --- > drivers/vfio/pci/vfio_pci.c | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > index 7c0779018b1b..ea5904ca6cbf 100644 > --- a/drivers/vfio/pci/vfio_pci.c > +++ b/drivers/vfio/pci/vfio_pci.c > @@ -60,6 +60,10 @@ module_param(enable_sriov, bool, 0644); > MODULE_PARM_DESC(enable_sriov, "Enable support for SR-IOV configuration. Enabling SR-IOV on a PF typically requires support of the userspace PF driver, enabling VFs without such support may result in non-functional VFs or PF."); > #endif > > +static bool disable_blocklist; > +module_param(disable_blocklist, bool, 0444); > +MODULE_PARM_DESC(disable_blocklist, "Disable device blocklist. If set, i.e. blocklist disabled, then blocklisted devices are allowed to be probed by vfio-pci."); > + > static inline bool vfio_vga_disabled(void) > { > #ifdef CONFIG_VFIO_PCI_VGA > @@ -69,6 +73,29 @@ static inline bool vfio_vga_disabled(void) > #endif > } > > +static bool vfio_pci_dev_in_blocklist(struct pci_dev *pdev) > +{ > + return false; > +} > + > +static bool vfio_pci_is_blocklisted(struct pci_dev *pdev) > +{ > + if (!vfio_pci_dev_in_blocklist(pdev)) > + return false; > + > + if (disable_blocklist) { > + pci_warn(pdev, > + "device blocklist disabled - allowing device %04x:%04x.\n", > + pdev->vendor, pdev->device); > + return false; > + } > + > + pci_warn(pdev, "%04x:%04x is blocklisted - probe will fail.\n", > + pdev->vendor, pdev->device); > + > + return true; > +} > + > /* > * Our VGA arbiter participation is limited since we don't know anything > * about the device itself. However, if the device is the only VGA device > @@ -1847,6 +1874,9 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) > struct iommu_group *group; > int ret; > > + if (vfio_pci_is_blocklisted(pdev)) > + return -EINVAL; > + > if (pdev->hdr_type != PCI_HEADER_TYPE_NORMAL) > return -EINVAL; > > @@ -2336,6 +2366,9 @@ static int __init vfio_pci_init(void) > > vfio_pci_fill_ids(); > > + if (disable_blocklist) > + pr_warn("device blocklist disabled.\n"); > + > return 0; > > out_driver: > -- > 2.26.2 >