Skip to content

vfio/nvgrace-gpu: Separate the fallback-mode open_device

Andrea Parri kvm lkml stable 1 version Applied

Status from this message: Applied to vfio next branch for v7.4. Thanks,

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest2 patches 4 repliesApplied

Changes in v2 from the cover letter

- Replace the usemem.memlength guards with a core-only open_device for the fallback table (Alex)
- Add patch 2
- Fallback open no longer fails when BAR0 cannot be mapped; Ankit confirmed fallback mode does not need that check
- Rebase on v7.3-rc7

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/2vfio/nvgrace-gpu: Use a core-only open_device in fallback modedrivers/vfio/pci/nvgrace-gpu/main.c+16 -11 reply
2/2vfio/nvgrace-gpu: Drop the usemem length check in open_devicedrivers/vfio/pci/nvgrace-gpu/main.c+2 -41 reply

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchAnkit Agrawal
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] vfio/nvgrace-gpu: Separate the fallback-mode open_device

In fallback mode, where the ACPI memory properties are missing or the C2C link is down, nvgrace-gpu opens a device through nvgrace_gpu_open_device() but closes it through vfio_pci_core_close_device(). The open registers an empty usemem range for poison handling that nothing unregisters, so a second open fails with -EBUSY, and the first open after an unbind hits a KASAN slab-use-after-free in register_pfn_address_space().

Patch 1 gives the fallback table its own open_device, as Alex suggested on v1, and is marked for stable. Patch 2 drops a usemem length check in nvgrace_gpu_open_device() that only existed for fallback mode.

Tested on x86-64 under virtme-ng with KASAN, not on Grace hardware. A QEMU cxl-type3 function, bound through driver_override, takes the fallback path and is opened through a noiommu VFIO cdev. On v7.3-rc7 the second open fails with -EBUSY and the open after unbind and rebind reports the use-after-free. With patch 1, and with the whole series, neither happens. Patch 2 only affects full mode, which this setup cannot reach.

Changes in v2:
- Replace the usemem.memlength guards with a core-only open_device for the fallback table (Alex)
- Add patch 2
- Fallback open no longer fails when BAR0 cannot be mapped; Ankit confirmed fallback mode does not need that check
- Rebase on v7.3-rc7

v1: https://lore.kernel.org/r/[email protected]/

Andrea Parri (2):
vfio/nvgrace-gpu: Use a core-only open_device in fallback mode vfio/nvgrace-gpu: Drop the usemem length check in open_device

 drivers/vfio/pci/nvgrace-gpu/main.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907

Signature · 1 line
2.53.0