Skip to content

Commit 1f97970

Browse files
gcabidduawilliam
authored andcommitted
vfio/pci: Add device denylist
Add denylist 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. To be accessed via vfio-pci, the user has to explicitly disable the denylist. The denylist can be disabled via the module parameter disable_denylist. Signed-off-by: Giovanni Cabiddu <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Reviewed-by: Fiona Trahe <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Alex Williamson <[email protected]>
1 parent 8b7beaf commit 1f97970

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

drivers/vfio/pci/vfio_pci.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ module_param(enable_sriov, bool, 0644);
6060
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.");
6161
#endif
6262

63+
static bool disable_denylist;
64+
module_param(disable_denylist, bool, 0444);
65+
MODULE_PARM_DESC(disable_denylist, "Disable use of device denylist. Disabling the denylist allows binding to devices with known errata that may lead to exploitable stability or security issues when accessed by untrusted users.");
66+
6367
static inline bool vfio_vga_disabled(void)
6468
{
6569
#ifdef CONFIG_VFIO_PCI_VGA
@@ -69,6 +73,29 @@ static inline bool vfio_vga_disabled(void)
6973
#endif
7074
}
7175

76+
static bool vfio_pci_dev_in_denylist(struct pci_dev *pdev)
77+
{
78+
return false;
79+
}
80+
81+
static bool vfio_pci_is_denylisted(struct pci_dev *pdev)
82+
{
83+
if (!vfio_pci_dev_in_denylist(pdev))
84+
return false;
85+
86+
if (disable_denylist) {
87+
pci_warn(pdev,
88+
"device denylist disabled - allowing device %04x:%04x.\n",
89+
pdev->vendor, pdev->device);
90+
return false;
91+
}
92+
93+
pci_warn(pdev, "%04x:%04x exists in vfio-pci device denylist, driver probing disallowed.\n",
94+
pdev->vendor, pdev->device);
95+
96+
return true;
97+
}
98+
7299
/*
73100
* Our VGA arbiter participation is limited since we don't know anything
74101
* about the device itself. However, if the device is the only VGA device
@@ -1856,6 +1883,9 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
18561883
struct iommu_group *group;
18571884
int ret;
18581885

1886+
if (vfio_pci_is_denylisted(pdev))
1887+
return -EINVAL;
1888+
18591889
if (pdev->hdr_type != PCI_HEADER_TYPE_NORMAL)
18601890
return -EINVAL;
18611891

@@ -2345,6 +2375,9 @@ static int __init vfio_pci_init(void)
23452375

23462376
vfio_pci_fill_ids();
23472377

2378+
if (disable_denylist)
2379+
pr_warn("device denylist disabled.\n");
2380+
23482381
return 0;
23492382

23502383
out_driver:

0 commit comments

Comments
 (0)