Skip to content

Commit 8704e89

Browse files
zhenywawilliam
authored andcommitted
vfio/pci: Fix OpRegion read
This is to fix incorrect pointer arithmetic which caused wrong OpRegion version returned, then VM driver got error to get wanted VBT block. We need to be safe to return correct data, so force pointer type for byte access. Fixes: 49ba1a2 ("vfio/pci: Add OpRegion 2.0+ Extended VBT support.") Cc: Colin Xu <[email protected]> Cc: Alex Williamson <[email protected]> Cc: Dmitry Torokhov <[email protected]> Cc: "Xu, Terrence" <[email protected]> Cc: "Gao, Fred" <[email protected]> Acked-by: Colin Xu <[email protected]> Signed-off-by: Zhenyu Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] [aw: line wrap] Signed-off-by: Alex Williamson <[email protected]>
1 parent 3b9a2d5 commit 8704e89

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/vfio/pci/vfio_pci_igd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ static ssize_t vfio_pci_igd_rw(struct vfio_pci_core_device *vdev,
9898
version = cpu_to_le16(0x0201);
9999

100100
if (igd_opregion_shift_copy(buf, &off,
101-
&version + (pos - OPREGION_VERSION),
101+
(u8 *)&version +
102+
(pos - OPREGION_VERSION),
102103
&pos, &remaining, bytes))
103104
return -EFAULT;
104105
}
@@ -121,7 +122,7 @@ static ssize_t vfio_pci_igd_rw(struct vfio_pci_core_device *vdev,
121122
OPREGION_SIZE : 0);
122123

123124
if (igd_opregion_shift_copy(buf, &off,
124-
&rvda + (pos - OPREGION_RVDA),
125+
(u8 *)&rvda + (pos - OPREGION_RVDA),
125126
&pos, &remaining, bytes))
126127
return -EFAULT;
127128
}

0 commit comments

Comments
 (0)