* [patch] vfio/pci: return -EFAULT if copy_to_user fails
@ 2016-02-25 7:52 Dan Carpenter
2016-02-25 9:28 ` Michael S. Tsirkin
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Dan Carpenter @ 2016-02-25 7:52 UTC (permalink / raw)
To: Alex Williamson
Cc: Eric Auger, Michael S. Tsirkin, Baptiste Reynal, Antonios Motakis,
kvm, kernel-janitors
The copy_to_user() function returns the number of bytes that were not
copied but we want to return -EFAULT on error here.
Fixes: 188ad9d6cbbc ('vfio/pci: Include sparse mmap capability for MSI-X table regions')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 1ce1d36..98059df 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -664,12 +664,11 @@ static long vfio_pci_ioctl(void *device_data,
info.cap_offset = 0;
} else {
vfio_info_cap_shift(&caps, sizeof(info));
- ret = copy_to_user((void __user *)arg +
- sizeof(info), caps.buf,
- caps.size);
- if (ret) {
+ if (copy_to_user((void __user *)arg +
+ sizeof(info), caps.buf,
+ caps.size)) {
kfree(caps.buf);
- return ret;
+ return -EFAULT;
}
info.cap_offset = sizeof(info);
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [patch] vfio/pci: return -EFAULT if copy_to_user fails
2016-02-25 7:52 [patch] vfio/pci: return -EFAULT if copy_to_user fails Dan Carpenter
@ 2016-02-25 9:28 ` Michael S. Tsirkin
2016-02-25 11:09 ` Dan Carpenter
2016-02-25 11:34 ` Michael S. Tsirkin
2016-02-28 14:05 ` Alex Williamson
2 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2016-02-25 9:28 UTC (permalink / raw)
To: Dan Carpenter
Cc: Alex Williamson, Eric Auger, Baptiste Reynal, Antonios Motakis,
kvm, kernel-janitors
On Thu, Feb 25, 2016 at 10:52:12AM +0300, Dan Carpenter wrote:
> The copy_to_user() function returns the number of bytes that were not
> copied but we want to return -EFAULT on error here.
>
> Fixes: 188ad9d6cbbc ('vfio/pci: Include sparse mmap capability for MSI-X table regions')
Where's this commit? In which tree?
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> index 1ce1d36..98059df 100644
> --- a/drivers/vfio/pci/vfio_pci.c
> +++ b/drivers/vfio/pci/vfio_pci.c
> @@ -664,12 +664,11 @@ static long vfio_pci_ioctl(void *device_data,
> info.cap_offset = 0;
> } else {
> vfio_info_cap_shift(&caps, sizeof(info));
> - ret = copy_to_user((void __user *)arg +
> - sizeof(info), caps.buf,
> - caps.size);
> - if (ret) {
> + if (copy_to_user((void __user *)arg +
> + sizeof(info), caps.buf,
> + caps.size)) {
> kfree(caps.buf);
> - return ret;
> + return -EFAULT;
> }
> info.cap_offset = sizeof(info);
> }
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] vfio/pci: return -EFAULT if copy_to_user fails
2016-02-25 9:28 ` Michael S. Tsirkin
@ 2016-02-25 11:09 ` Dan Carpenter
2016-02-25 11:33 ` Michael S. Tsirkin
0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2016-02-25 11:09 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Alex Williamson, Eric Auger, Baptiste Reynal, Antonios Motakis,
kvm, kernel-janitors
On Thu, Feb 25, 2016 at 11:28:54AM +0200, Michael S. Tsirkin wrote:
> On Thu, Feb 25, 2016 at 10:52:12AM +0300, Dan Carpenter wrote:
> > The copy_to_user() function returns the number of bytes that were not
> > copied but we want to return -EFAULT on error here.
> >
> > Fixes: 188ad9d6cbbc ('vfio/pci: Include sparse mmap capability for MSI-X table regions')
>
> Where's this commit? In which tree?
linux-next. It only has Alex's signed off by. So likely my patch will
be folded in?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] vfio/pci: return -EFAULT if copy_to_user fails
2016-02-25 11:09 ` Dan Carpenter
@ 2016-02-25 11:33 ` Michael S. Tsirkin
0 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2016-02-25 11:33 UTC (permalink / raw)
To: Dan Carpenter
Cc: Alex Williamson, Eric Auger, Baptiste Reynal, Antonios Motakis,
kvm, kernel-janitors
On Thu, Feb 25, 2016 at 02:09:44PM +0300, Dan Carpenter wrote:
> On Thu, Feb 25, 2016 at 11:28:54AM +0200, Michael S. Tsirkin wrote:
> > On Thu, Feb 25, 2016 at 10:52:12AM +0300, Dan Carpenter wrote:
> > > The copy_to_user() function returns the number of bytes that were not
> > > copied but we want to return -EFAULT on error here.
> > >
> > > Fixes: 188ad9d6cbbc ('vfio/pci: Include sparse mmap capability for MSI-X table regions')
> >
> > Where's this commit? In which tree?
>
> linux-next. It only has Alex's signed off by. So likely my patch will
> be folded in?
>
> regards,
> dan carpenter
BTW, vfio repeats this in otherplaces.
I'll fix it up.
--
MST
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] vfio/pci: return -EFAULT if copy_to_user fails
2016-02-25 7:52 [patch] vfio/pci: return -EFAULT if copy_to_user fails Dan Carpenter
2016-02-25 9:28 ` Michael S. Tsirkin
@ 2016-02-25 11:34 ` Michael S. Tsirkin
2016-02-28 14:05 ` Alex Williamson
2 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2016-02-25 11:34 UTC (permalink / raw)
To: Dan Carpenter
Cc: Alex Williamson, Eric Auger, Baptiste Reynal, Antonios Motakis,
kvm, kernel-janitors
On Thu, Feb 25, 2016 at 10:52:12AM +0300, Dan Carpenter wrote:
> The copy_to_user() function returns the number of bytes that were not
> copied but we want to return -EFAULT on error here.
>
> Fixes: 188ad9d6cbbc ('vfio/pci: Include sparse mmap capability for MSI-X table regions')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
I posted a patch to fix up all other places.
> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> index 1ce1d36..98059df 100644
> --- a/drivers/vfio/pci/vfio_pci.c
> +++ b/drivers/vfio/pci/vfio_pci.c
> @@ -664,12 +664,11 @@ static long vfio_pci_ioctl(void *device_data,
> info.cap_offset = 0;
> } else {
> vfio_info_cap_shift(&caps, sizeof(info));
> - ret = copy_to_user((void __user *)arg +
> - sizeof(info), caps.buf,
> - caps.size);
> - if (ret) {
> + if (copy_to_user((void __user *)arg +
> + sizeof(info), caps.buf,
> + caps.size)) {
> kfree(caps.buf);
> - return ret;
> + return -EFAULT;
> }
> info.cap_offset = sizeof(info);
> }
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] vfio/pci: return -EFAULT if copy_to_user fails
2016-02-25 7:52 [patch] vfio/pci: return -EFAULT if copy_to_user fails Dan Carpenter
2016-02-25 9:28 ` Michael S. Tsirkin
2016-02-25 11:34 ` Michael S. Tsirkin
@ 2016-02-28 14:05 ` Alex Williamson
2 siblings, 0 replies; 6+ messages in thread
From: Alex Williamson @ 2016-02-28 14:05 UTC (permalink / raw)
To: Dan Carpenter
Cc: Eric Auger, Michael S. Tsirkin, Baptiste Reynal, Antonios Motakis,
kvm, kernel-janitors
On Thu, 25 Feb 2016 10:52:12 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> The copy_to_user() function returns the number of bytes that were not
> copied but we want to return -EFAULT on error here.
>
> Fixes: 188ad9d6cbbc ('vfio/pci: Include sparse mmap capability for MSI-X table regions')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> index 1ce1d36..98059df 100644
> --- a/drivers/vfio/pci/vfio_pci.c
> +++ b/drivers/vfio/pci/vfio_pci.c
> @@ -664,12 +664,11 @@ static long vfio_pci_ioctl(void *device_data,
> info.cap_offset = 0;
> } else {
> vfio_info_cap_shift(&caps, sizeof(info));
> - ret = copy_to_user((void __user *)arg +
> - sizeof(info), caps.buf,
> - caps.size);
> - if (ret) {
> + if (copy_to_user((void __user *)arg +
> + sizeof(info), caps.buf,
> + caps.size)) {
> kfree(caps.buf);
> - return ret;
> + return -EFAULT;
> }
> info.cap_offset = sizeof(info);
> }
Applied to next. Thanks,
Alex
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-02-28 14:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-25 7:52 [patch] vfio/pci: return -EFAULT if copy_to_user fails Dan Carpenter
2016-02-25 9:28 ` Michael S. Tsirkin
2016-02-25 11:09 ` Dan Carpenter
2016-02-25 11:33 ` Michael S. Tsirkin
2016-02-25 11:34 ` Michael S. Tsirkin
2016-02-28 14:05 ` Alex Williamson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox