All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Garzarella <sgarzare@redhat.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	Gautam Dawar <gautam.dawar@xilinx.com>,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	kernel-janitors@vger.kernel.org, kvm@vger.kernel.org,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH] vhost-vdpa: return -EFAULT on copy_to_user() failure
Date: Mon, 23 May 2022 12:44:58 +0200	[thread overview]
Message-ID: <20220523104458.exaf2zb3lua76ibf@sgarzare-redhat> (raw)
In-Reply-To: <YotG1vXKXXSayr63@kili>

On Mon, May 23, 2022 at 11:33:26AM +0300, Dan Carpenter wrote:
>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 <dan.carpenter@oracle.com>
>---
> drivers/vhost/vdpa.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)

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

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


WARNING: multiple messages have this Message-ID (diff)
From: Stefano Garzarella <sgarzare@redhat.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: kvm@vger.kernel.org, "Michael S. Tsirkin" <mst@redhat.com>,
	kernel-janitors@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Gautam Dawar <gautam.dawar@xilinx.com>
Subject: Re: [PATCH] vhost-vdpa: return -EFAULT on copy_to_user() failure
Date: Mon, 23 May 2022 12:44:58 +0200	[thread overview]
Message-ID: <20220523104458.exaf2zb3lua76ibf@sgarzare-redhat> (raw)
In-Reply-To: <YotG1vXKXXSayr63@kili>

On Mon, May 23, 2022 at 11:33:26AM +0300, Dan Carpenter wrote:
>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 <dan.carpenter@oracle.com>
>---
> drivers/vhost/vdpa.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)

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

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

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  reply	other threads:[~2022-05-23 10:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-23  8:33 [PATCH] vhost-vdpa: return -EFAULT on copy_to_user() failure Dan Carpenter
2022-05-23  8:33 ` Dan Carpenter
2022-05-23 10:44 ` Stefano Garzarella [this message]
2022-05-23 10:44   ` Stefano Garzarella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220523104458.exaf2zb3lua76ibf@sgarzare-redhat \
    --to=sgarzare@redhat.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dan.carpenter@oracle.com \
    --cc=gautam.dawar@xilinx.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.