Bug 216970 - When VM using vfio-pci driver to pci device passthrough, host can access VM's pci device with libpciaccess library.
Summary: When VM using vfio-pci driver to pci device passthrough, host can access VM's...
Status: RESOLVED ANSWERED
Alias: None
Product: Drivers
Classification: Unclassified
Component: PCI (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_pci@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-27 09:02 UTC by sglee97
Modified: 2023-01-27 17:58 UTC (History)
1 user (show)

See Also:
Kernel Version: 5.15.0
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Upload text data to vfio-pci passthrough GPU VRAM with using nvatools (2.50 MB, image/png)
2023-01-27 09:02 UTC, sglee97
Details
VM lspci -vvv (8.27 KB, text/plain)
2023-01-27 09:03 UTC, sglee97
Details
Host lspci -vvv (44.42 KB, text/plain)
2023-01-27 09:03 UTC, sglee97
Details

Description sglee97 2023-01-27 09:02:25 UTC
Created attachment 303656 [details]
Upload text data to vfio-pci passthrough GPU VRAM with using nvatools

1) Release of Ubuntu
  Host - Ubuntu 20.04.5 LTS / Release : 20.04
  Guest - Ubuntu 18.04.6 LTS / Release : 18.04

2) Kernel version
  Host - 5.15.0-57-generic
  Guest - 5.4.0-137-generic

3) Version of the package
libpciaccess0:
  Installed: 0.16-0ubuntu1
  Candidate: 0.16-0ubuntu1

libpciaccess-dev:
  Installed: 0.16-0ubuntu1
  Candidate: 0.16-0ubuntu1

4) Expected to happen
When the virtual machine is running, the Host could not access the virtual machine's pci passthrough device via libpciaccess.

5) Happened instead
When the virtual machine is running, the host can access the virtual machine's pci passthrough device via libpciaccess.

In this case, host can interrupt passthrough pci device, or access passthrough pci device memory to leak virtual machine data.

We checked this by creating a virtual machine using vfio-pci passthrough GPU in QEMU.

In addition, when running GPU applications such as CUDA in a virtual machine, we found that data inside passthrough GPU VRAM can be accessed from the host via libpciaccess(nvatools).

We proceeded as follows.
 1. Create and run VMs with vfio-pci passthrough GPU.

 2. Upload text data from the host via nvatools to the VRAM on the passthrough GPU.

 3. The VM can see the text data in the GPU VRAM.
Comment 1 sglee97 2023-01-27 09:03:11 UTC
Created attachment 303657 [details]
VM lspci -vvv
Comment 2 sglee97 2023-01-27 09:03:32 UTC
Created attachment 303658 [details]
Host lspci -vvv
Comment 3 Bjorn Helgaas 2023-01-27 17:58:23 UTC
Closing this as "answered" because while this kind of protection would be desirable, we don't have hardware mechanisms yet to support it.  See Alex's response at https://lore.kernel.org/r/20230127103205.50795e59.alex.williamson@redhat.com

Note You need to log in before you can comment on or make changes to this bug.