vfio/pci: Fix information leak in vfio_rom_read()
PATCH 1/1 vfio/pci: Fix information leak in vfio_rom_read()
vfio_rom_read() can leak uninitialized stack data to the guest when a read occurs at the end boundary of the ROM BAR.
Fix this by initializing the val union to 0xff, matching the ROM initialization pattern used in vfio_pci_load_rom().
--- hw/vfio/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/vfio/pci.c +1 -1
@@ -1142,7 +1142,7 @@ static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size)uint16_t word;uint32_t dword;uint64_t qword; - } val; + } val = { .qword = ~0ULL };uint64_t data =0 ;/* Load the ROM lazily when the guest tries to read it */
Signature · 1 line
2.54.0
Looks good to me!
BR,
Mario
Quoted 28 lines · Cédric Le Goater
vfio_rom_read()can leak uninitialized stack data to the guest when a read occurs at the end boundary of the ROM BAR.Fix this by initializing the val union to
0xff, matching the ROM initialization pattern used invfio_pci_load_rom().Signed-off-by Cédric Le Goater <[email protected]>--- hw/vfio/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/vfio/pci.c +1
-2@@ -1142,7 +1142,7 @@ static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size)uint16_t word;uint32_t dword;uint64_t qword; - } val; + } val = { .qword = ~0ULL };uint64_t data =0 ;/* Load the ROM lazily when the guest tries to read it */ --2.54.0
Quoted 10 lines · Cédric Le Goater
vfio_rom_read()can leak uninitialized stack data to the guest when a read occurs at the end boundary of the ROM BAR.Fix this by initializing the val union to
0xff, matching the ROM initialization pattern used invfio_pci_load_rom().Signed-off-by Cédric Le Goater <[email protected]>--- hw/vfio/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines · Cédric Le Goater
vfio_rom_read()can leak uninitialized stack data to the guest when a read occurs at the end boundary of the ROM BAR.Fix this by initializing the val union to
0xff, matching the ROM initialization pattern used invfio_pci_load_rom().Signed-off-by Cédric Le Goater <[email protected]>--- hw/vfio/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/vfio/pci.c +0
-0
hw/vfio/pci.c static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size) · line 1148
Quoted 8 lines
hw/vfio/pci.c +1
-1@@ -1142,7 +1142,7 @@ static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size)uint16_t word;uint32_t dword;uint64_t qword; - } val; + } val = { .qword = ~0ULL };uint64_t data =0 ;/* Load the ROM lazily when the guest tries to read it */
Applied to
https://github.com/legoater/qemu vfio-next
Thanks,
C.