vfio/pci: Init the count variable in collecting hot-reset devices
Subsystems (2)
PATCH 1/1 vfio/pci: Init the count variable in collecting hot-reset devices
The count variable is used without initialization, it results in mistakes in the device counting and crashes the userspace if the get hot reset info path is triggered.
--- drivers/vfio/pci/vfio_pci_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vfio/pci/vfio_pci_core.c +1 -1
@@ -1260,7 +1260,7 @@ static int vfio_pci_ioctl_get_pci_hot_reset_info(struct vfio_pci_hot_reset_info hdr;struct vfio_pci_fill_info fill = {};bool slot = false; -int ret, count; +int ret, count =0 ;if (copy_from_user (&hdr, arg, minsz))return -EFAULT ;
Signature · 1 line
2.34.1
Quoted 7 lines
From: Yi Liu <[email protected]>
Sent: Wednesday, July 10, 2024 8:42 AMThe count variable is used without initialization, it results in mistakes in the device counting and crashes the userspace if the get hot reset info path is triggered.
Quoted 5 lines
Fixes f6944d4a0b87 ("vfio/pci: Collect hot-reset devices to local buffer")Reported-by Žilvinas Žaltiena <[email protected]>Cc Beld Zhang <[email protected]>Signed-off-by Yi Liu <[email protected]>
Quoted 18 lines · On Tue, 9 Jul 2024 17:41:50 -0700 Yi Liu <[email protected]> wrote:
The count variable is used without initialization, it results in mistakes in the device counting and crashes the userspace if the get hot reset info path is triggered.
Fixes f6944d4a0b87 ("vfio/pci: Collect hot-reset devices to local buffer")Reported-by Žilvinas Žaltiena <[email protected]>Cc Beld Zhang <[email protected]>Signed-off-by Yi Liu <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/vfio/pci/vfio_pci_core.c +0
-0
drivers/vfio/pci/vfio_pci_core.c static int vfio_pci_ioctl_get_pci_hot_reset_info( · line 1266
Quoted 8 lines
drivers/vfio/pci/vfio_pci_core.c +1
-1@@ -1260,7 +1260,7 @@ static int vfio_pci_ioctl_get_pci_hot_reset_info(struct vfio_pci_hot_reset_info hdr;struct vfio_pci_fill_info fill = {};bool slot = false; -int ret, count; +int ret, count =0 ;if (copy_from_user (&hdr, arg, minsz))return -EFAULT ;
Thanks, Yi! I just got back from a long weekend and was planning to debug this. Thanks for finding the bug!
Alex
Quoted 4 lines · Yi Liu
The count variable is used without initialization, it results in mistakes in the device counting and crashes the userspace if the get hot reset info path is triggered.
Quoted 8 lines
Fixes f6944d4a0b87 ("vfio/pci: Collect hot-reset devices to local buffer")Reported-by Žilvinas Žaltiena <[email protected]>Cc Beld Zhang <[email protected]>Signed-off-by Yi Liu <[email protected]>--- drivers/vfio/pci/vfio_pci_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Jason