* [PATCH] fix vhost ioctl handling for 32-bit
@ 2009-12-17 19:44 David Stevens
2009-12-20 12:02 ` Michael S. Tsirkin
0 siblings, 1 reply; 3+ messages in thread
From: David Stevens @ 2009-12-17 19:44 UTC (permalink / raw)
To: mst, rusty; +Cc: kvm
[-- Attachment #1: Type: text/plain, Size: 1075 bytes --]
VHOST_GET_FEATURES returns high-order garbage on 32-bit
machines. This patch fixes it to use 64 bits throughout.
+-DLS
[in-line for viewing, attached to avoid whitespace mangling]
Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
--- a/drivers/vhost/net.c 2009-11-17 22:51:56.000000000 -0800
+++ b/drivers/vhost/net.c 2009-12-17 11:31:51.000000000 -0800
@@ -563,7 +563,7 @@
{
struct vhost_net *n = f->private_data;
void __user *argp = (void __user *)arg;
- u32 __user *featurep = argp;
+ u64 __user *featurep = (u64 __user *)argp;
struct vhost_vring_file backend;
u64 features;
int r;
@@ -577,7 +577,7 @@
features = VHOST_FEATURES;
return put_user(features, featurep);
case VHOST_SET_FEATURES:
- r = get_user(features, featurep);
+ r = copy_from_user(&features, featurep, sizeof features);
/* No features for now */
if (r < 0)
return r;
[-- Attachment #2: VH1.patch --]
[-- Type: application/octet-stream, Size: 638 bytes --]
--- a/drivers/vhost/net.c 2009-11-17 22:51:56.000000000 -0800
+++ b/drivers/vhost/net.c 2009-12-17 11:31:51.000000000 -0800
@@ -563,7 +563,7 @@
{
struct vhost_net *n = f->private_data;
void __user *argp = (void __user *)arg;
- u32 __user *featurep = argp;
+ u64 __user *featurep = (u64 __user *)argp;
struct vhost_vring_file backend;
u64 features;
int r;
@@ -577,7 +577,7 @@
features = VHOST_FEATURES;
return put_user(features, featurep);
case VHOST_SET_FEATURES:
- r = get_user(features, featurep);
+ r = copy_from_user(&features, featurep, sizeof features);
/* No features for now */
if (r < 0)
return r;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fix vhost ioctl handling for 32-bit
2009-12-17 19:44 [PATCH] fix vhost ioctl handling for 32-bit David Stevens
@ 2009-12-20 12:02 ` Michael S. Tsirkin
2009-12-21 20:05 ` David Stevens
0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2009-12-20 12:02 UTC (permalink / raw)
To: David Stevens; +Cc: rusty, kvm
On Thu, Dec 17, 2009 at 12:44:55PM -0700, David Stevens wrote:
> VHOST_GET_FEATURES returns high-order garbage on 32-bit
> machines. This patch fixes it to use 64 bits throughout.
>
> +-DLS
>
> [in-line for viewing, attached to avoid whitespace mangling]
>
> Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
>
> --- a/drivers/vhost/net.c 2009-11-17 22:51:56.000000000 -0800
> +++ b/drivers/vhost/net.c 2009-12-17 11:31:51.000000000 -0800
> @@ -563,7 +563,7 @@
> {
> struct vhost_net *n = f->private_data;
> void __user *argp = (void __user *)arg;
> - u32 __user *featurep = argp;
> + u64 __user *featurep = (u64 __user *)argp;
> struct vhost_vring_file backend;
> u64 features;
> int r;
> @@ -577,7 +577,7 @@
> features = VHOST_FEATURES;
> return put_user(features, featurep);
> case VHOST_SET_FEATURES:
> - r = get_user(features, featurep);
> + r = copy_from_user(&features, featurep, sizeof features);
> /* No features for now */
> if (r < 0)
> return r;
>
Thanks very much for the report and the patch.
I tweaked the description and the code a bit (both GET and SET need
to be fixed). Could you pls approve this still works for you as well? Also,
out of interest, could you please share which application and on which
platform are you using vhost net? Thanks!
--->
Subject: vhost: fix high 32 bit in FEATURES ioctls
VHOST_GET_FEATURES fails to initialize high-order 32 bits
in the returned value, and VHOST_SET_FEATURES fails to check them.
This patch fixes it to use 64 bits throughout.
Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 22d5fef..d6db10c 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -563,7 +563,7 @@ static long vhost_net_ioctl(struct file *f, unsigned int ioctl,
{
struct vhost_net *n = f->private_data;
void __user *argp = (void __user *)arg;
- u32 __user *featurep = argp;
+ u64 __user *featurep = argp;
struct vhost_vring_file backend;
u64 features;
int r;
@@ -575,10 +575,9 @@ static long vhost_net_ioctl(struct file *f, unsigned int ioctl,
return vhost_net_set_backend(n, backend.index, backend.fd);
case VHOST_GET_FEATURES:
features = VHOST_FEATURES;
- return put_user(features, featurep);
+ return copy_to_user(featurep, &features, sizeof features);
case VHOST_SET_FEATURES:
- r = get_user(features, featurep);
- /* No features for now */
+ r = copy_from_user(&features, featurep, sizeof features);
if (r < 0)
return r;
if (features & ~VHOST_FEATURES)
--
MST
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fix vhost ioctl handling for 32-bit
2009-12-20 12:02 ` Michael S. Tsirkin
@ 2009-12-21 20:05 ` David Stevens
0 siblings, 0 replies; 3+ messages in thread
From: David Stevens @ 2009-12-21 20:05 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: kvm, kvm-owner, rusty
Michael,
There is a 64-bit put_user(), so SET actually works already, but
there just isn't a 64-bit get_user().
It doesn't hurt to make them symmetric, though. The changes look
fine to me, if you want to do both.
I'm looking at adding mergeable rx buffer support and doing the
development work on a Centrino vPro. I've run into other problems
with feature bits setting from your qemu git tree; will send a patch
for that when I get it straightened out (unless someone else gets to
it first, while I'm on vacation).
+-DLS
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-12-21 20:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-17 19:44 [PATCH] fix vhost ioctl handling for 32-bit David Stevens
2009-12-20 12:02 ` Michael S. Tsirkin
2009-12-21 20:05 ` David Stevens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox