Skip to content

Commit 479af0d

Browse files
rananta468gregkh
authored andcommitted
vfio: Fix ksize arg while copying user struct in vfio_df_ioctl_bind_iommufd()
commit 2f03f21 upstream. For the cases where user includes a non-zero value in 'token_uuid_ptr' field of 'struct vfio_device_bind_iommufd', the copy_struct_from_user() in vfio_df_ioctl_bind_iommufd() fails with -E2BIG. For the 'minsz' passed, copy_struct_from_user() expects the newly introduced field to be zero-ed, which would be incorrect in this case. Fix this by passing the actual size of the kernel struct. If working with a newer userspace, copy_struct_from_user() would copy the 'token_uuid_ptr' field, and if working with an old userspace, it would zero out this field, thus still retaining backward compatibility. Fixes: 86624ba ("vfio/pci: Do vf_token checks for VFIO_DEVICE_BIND_IOMMUFD") Cc: stable@vger.kernel.org Signed-off-by: Raghavendra Rao Ananta <rananta@google.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/20251031170603.2260022-2-rananta@google.com Signed-off-by: Alex Williamson <alex@shazbot.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8716a84 commit 479af0d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/vfio/device_cdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ long vfio_df_ioctl_bind_iommufd(struct vfio_device_file *df,
9999
return ret;
100100
if (user_size < minsz)
101101
return -EINVAL;
102-
ret = copy_struct_from_user(&bind, minsz, arg, user_size);
102+
ret = copy_struct_from_user(&bind, sizeof(bind), arg, user_size);
103103
if (ret)
104104
return ret;
105105

0 commit comments

Comments
 (0)