vhost-vdpa: return -EFAULT on copy_to_user() failure
Subsystems (4)
PATCH 1/1 vhost-vdpa: return -EFAULT on copy_to_user() failure
The copy_to_user() function returns the number of bytes remaining to be copied. However, we need to return a negative error code, -EFAULT, to the user.
Fixes 87f4c217413a ("vhost-vdpa: introduce uAPI to get the number of virtqueue groups")
Fixes e96ef636f154 ("vhost-vdpa: introduce uAPI to get the number of address spaces")
Signed-off-by Dan Carpenter <[email protected]>
--- drivers/vhost/vdpa.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/vhost/vdpa.c +5 -3
@@ -609,11 +609,13 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, r =vhost_vdpa_get_vring_num (v, argp);break ;case VHOST_VDPA_GET_GROUP_NUM : - r =copy_to_user (argp, &v->vdpa->ngroups, -sizeof (v->vdpa->ngroups)); +if (copy_to_user (argp, &v->vdpa->ngroups, +sizeof (v->vdpa->ngroups))) + r = -EFAULT ;break ;case VHOST_VDPA_GET_AS_NUM : - r =copy_to_user (argp, &v->vdpa->nas,sizeof (v->vdpa->nas)); +if (copy_to_user (argp, &v->vdpa->nas,sizeof (v->vdpa->nas))) + r = -EFAULT ;break ;case VHOST_SET_LOG_BASE :case VHOST_SET_LOG_FD :
Signature · 6 lines
2.35.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 10 lines · Dan Carpenter
The
copy_to_user()function returns the number of bytes remaining to be copied. However, we need to return a negative error code,-EFAULT, to the user.Fixes 87f4c217413a ("vhost-vdpa: introduce uAPI to get the number of virtqueue groups")Fixes e96ef636f154 ("vhost-vdpa: introduce uAPI to get the number of address spaces")Signed-off-by Dan Carpenter <[email protected]>---
drivers/vhost/vdpa.c| 8 +++++---1 file changed, 5 insertions(+), 3 deletions(-)
Reviewed-by Stefano Garzarella <[email protected]>
Quoted 30 lines
drivers/vhost/vdpa.c +5
-3@@ -609,11 +609,13 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, r =vhost_vdpa_get_vring_num (v, argp);break ;case VHOST_VDPA_GET_GROUP_NUM : - r =copy_to_user (argp, &v->vdpa->ngroups, -sizeof (v->vdpa->ngroups)); +if (copy_to_user (argp, &v->vdpa->ngroups, +sizeof (v->vdpa->ngroups))) + r = -EFAULT ;break ;case VHOST_VDPA_GET_AS_NUM : - r =copy_to_user (argp, &v->vdpa->nas,sizeof (v->vdpa->nas)); +if (copy_to_user (argp, &v->vdpa->nas,sizeof (v->vdpa->nas))) + r = -EFAULT ;break ;case VHOST_SET_LOG_BASE :case VHOST_SET_LOG_FD :Signature · 6 lines
2.35.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization