kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] vhost_vdpa: return -EFAULT if copy_to_user() fails
Date: Wed, 02 Dec 2020 08:13:53 +0000	[thread overview]
Message-ID: <a94dfe3f-2202-7848-ed61-a8b682a7643d@redhat.com> (raw)
In-Reply-To: <X8c32z5EtDsMyyIL@mwanda>


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

  reply	other threads:[~2020-12-02  8:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02  6:44 [PATCH] vhost_vdpa: return -EFAULT if copy_to_user() fails Dan Carpenter
2020-12-02  8:13 ` Jason Wang [this message]
2020-12-02  9:14 ` 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=a94dfe3f-2202-7848-ed61-a8b682a7643d@redhat.com \
    --to=jasowang@redhat.com \
    --cc=dan.carpenter@oracle.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 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).