vhost_vdpa: return -EFAULT if copy_to_user() fails
Subsystems (4)
PATCH 1/1 vhost_vdpa: return -EFAULT if copy_to_user() fails
The copy_to_user() function returns the number of bytes remaining to be copied but this should return -EFAULT to the user.
Fixes 1b48dc03e575 ("vhost: vdpa: report iova range")
Signed-off-by Dan Carpenter <[email protected]>
--- drivers/vhost/vdpa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/vhost/vdpa.c +3 -1
@@ -344,7 +344,9 @@ static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp) .last = v->range.last, }; -return copy_to_user (argp, &range,sizeof (range)); +if (copy_to_user (argp, &range,sizeof (range))) +return -EFAULT ; +return 0 ; } static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
Signature · 1 line
2.29.2
Quoted 14 lines · Dan Carpenter
The
copy_to_user()function returns the number of bytes remaining to be copied but this should return-EFAULTto the user.Fixes 1b48dc03e575 ("vhost: vdpa: report iova range")Signed-off-by Dan Carpenter <[email protected]>--- drivers/vhost/vdpa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/vhost/vdpa.c +0
-0
drivers/vhost/vdpa.c static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp) · line 352
Quoted 10 lines
drivers/vhost/vdpa.c +3
-1@@ -344,7 +344,9 @@ static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp) .last = v->range.last, }; -return copy_to_user (argp, &range,sizeof (range)); +if (copy_to_user (argp, &range,sizeof (range))) +return -EFAULT ; +return 0 ; } static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
Acked-by Jason Wang <[email protected]>
Thanks
Quoted 8 lines · Dan Carpenter
The
copy_to_user()function returns the number of bytes remaining to be copied but this should return-EFAULTto the user.Fixes 1b48dc03e575 ("vhost: vdpa: report iova range")Signed-off-by Dan Carpenter <[email protected]>---
drivers/vhost/vdpa.c| 4 +++-1 file changed, 3 insertions(+), 1 deletion(-)
Reviewed-by Stefano Garzarella <[email protected]>
Quoted 24 lines
drivers/vhost/vdpa.c +3
-1@@ -344,7 +344,9 @@ static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp) .last = v->range.last, }; -return copy_to_user (argp, &range,sizeof (range)); +if (copy_to_user (argp, &range,sizeof (range))) +return -EFAULT ; +return 0 ; } static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,Signature · 6 lines
2.29.2 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization