kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vhost_vdpa: return -EFAULT if copy_to_user() fails
@ 2020-12-02  6:44 Dan Carpenter
  2020-12-02  8:13 ` Jason Wang
  2020-12-02  9:14 ` Stefano Garzarella
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2020-12-02  6:44 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang; +Cc: kvm, virtualization, kernel-janitors

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 <dan.carpenter@oracle.com>
---
 drivers/vhost/vdpa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index d6a37b66770b..ef688c8c0e0e 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -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,
-- 
2.29.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] vhost_vdpa: return -EFAULT if copy_to_user() fails
  2020-12-02  6:44 [PATCH] vhost_vdpa: return -EFAULT if copy_to_user() fails Dan Carpenter
@ 2020-12-02  8:13 ` Jason Wang
  2020-12-02  9:14 ` Stefano Garzarella
  1 sibling, 0 replies; 3+ messages in thread
From: Jason Wang @ 2020-12-02  8:13 UTC (permalink / raw)
  To: Dan Carpenter, Michael S. Tsirkin; +Cc: kvm, virtualization, kernel-janitors


On 2020/12/2 下午2:44, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>
> ---
>   drivers/vhost/vdpa.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index d6a37b66770b..ef688c8c0e0e 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -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 <jasowang@redhat.com>

Thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] vhost_vdpa: return -EFAULT if copy_to_user() fails
  2020-12-02  6:44 [PATCH] vhost_vdpa: return -EFAULT if copy_to_user() fails Dan Carpenter
  2020-12-02  8:13 ` Jason Wang
@ 2020-12-02  9:14 ` Stefano Garzarella
  1 sibling, 0 replies; 3+ messages in thread
From: Stefano Garzarella @ 2020-12-02  9:14 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Michael S. Tsirkin, Jason Wang, kernel-janitors, kvm, virtualization

On Wed, Dec 02, 2020 at 09:44:43AM +0300, Dan Carpenter wrote:
>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 <dan.carpenter@oracle.com>
>---
> drivers/vhost/vdpa.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

>
>diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
>index d6a37b66770b..ef688c8c0e0e 100644
>--- a/drivers/vhost/vdpa.c
>+++ b/drivers/vhost/vdpa.c
>@@ -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,
>-- 
>2.29.2
>
>_______________________________________________
>Virtualization mailing list
>Virtualization@lists.linux-foundation.org
>https://lists.linuxfoundation.org/mailman/listinfo/virtualization
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-02  9:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-02  6:44 [PATCH] vhost_vdpa: return -EFAULT if copy_to_user() fails Dan Carpenter
2020-12-02  8:13 ` Jason Wang
2020-12-02  9:14 ` Stefano Garzarella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).