Skip to content

RFC vfio/pci: Block and audit accesses to unassigned config regions

Chathura Rajapaksha audit kvm lkml llvm oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2block accesses to unassigned PCI config regionsdrivers/vfio/pci/vfio_pci_config.c+121 -11 reply
2/2audit accesses to unassigned PCI config regionsdrivers/vfio/pci/Kconfig drivers/vfio/pci/vfio_pci_config.c include/uapi/linux/audit.h+57 -24 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/2] vfio/pci: Block and audit accesses to unassigned config regions

Some PCIe devices trigger PCI bus errors when accesses are made to unassigned regions within their PCI configuration space. On certain platforms, this can lead to host system hangs or reboots.

The current vfio-pci driver allows guests to access unassigned regions in the PCI configuration space. Therefore, when such a device is passed through to a guest, the guest can induce a host system hang or reboot through crafted configuration space accesses, posing a threat to system availability.

This patch series introduces:
1. Support for blocking guest accesses to unassigned
PCI configuration space, and the ability to bypass this access control for specific devices. The patch introduces three module parameters:

block_pci_unassigned_write:
Blocks write accesses to unassigned config space regions.

block_pci_unassigned_read:
Blocks read accesses to unassigned config space regions.

uaccess_allow_ids:
Specifies the devices for which the above access control is bypassed. The value is a comma-separated list of device IDs in <vendor_id>:<device_id> format.

Example usage:
To block guest write accesses to unassigned config regions for all passed through devices except for the device with vendor ID 0x1234 and device ID 0x5678:

block_pci_unassigned_write=1 uaccess_allow_ids=1234:5678

2. Auditing support for config space accesses to unassigned regions. When enabled, this logs such accesses for all passthrough devices. This feature is controlled via a new Kconfig option:

CONFIG_VFIO_PCI_UNASSIGNED_ACCESS_AUDIT

A new audit event type, AUDIT_VFIO, has been introduced to support this, allowing administrators to monitor and investigate suspicious behavior by guests.

This proposal is intended to harden VFIO passthrough in environments where guests are untrusted or system reliability is critical.

Any feedback and comments are greatly appreciated.

Chathura Rajapaksha (2):
block accesses to unassigned PCI config regions
audit accesses to unassigned PCI config regions

 drivers/vfio/pci/Kconfig           |  12 +++
 drivers/vfio/pci/vfio_pci_config.c | 164 ++++++++++++++++++++++++++++-
 include/uapi/linux/audit.h         |   1 +
 3 files changed, 176 insertions(+), 1 deletion(-)

base-commit: f1a3944c860b0615d0513110d8cf62bb94adbb41

Signature · 1 line
2.34.1