]> Git Repo - linux.git/commitdiff
vfio/pci: clean up a type in vfio_pci_ioctl_pci_hot_reset_groups()
authorDan Carpenter <[email protected]>
Thu, 12 Sep 2024 08:49:10 +0000 (11:49 +0300)
committerAlex Williamson <[email protected]>
Thu, 12 Sep 2024 20:15:07 +0000 (14:15 -0600)
The "array_count" value comes from the copy_from_user() in
vfio_pci_ioctl_pci_hot_reset().  If the user passes a value larger than
INT_MAX then we'll pass a negative value to kcalloc() which triggers an
allocation failure and a stack trace.

It's better to make the type unsigned so that if (array_count > count)
returns -EINVAL instead.

Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Jason Gunthorpe <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alex Williamson <[email protected]>
drivers/vfio/pci/vfio_pci_core.c

index 2127b82d301a25a06abbb1a8f153b395ebec240d..8343f802cf939355cf51f10fcc93005622c9e848 100644 (file)
@@ -1323,7 +1323,7 @@ out:
 
 static int
 vfio_pci_ioctl_pci_hot_reset_groups(struct vfio_pci_core_device *vdev,
-                                   int array_count, bool slot,
+                                   u32 array_count, bool slot,
                                    struct vfio_pci_hot_reset __user *arg)
 {
        int32_t *group_fds;
This page took 0.047417 seconds and 4 git commands to generate.