[PATCH 3.16 156/204] macvtap: fix TUNSETSNDBUF values > 64k

From: Ben Hutchings
Date: Thu Dec 28 2017 - 12:24:53 EST


3.16.52-rc1 review patch. If anyone has any objections, please let me know.

------------------

From: "Michael S. Tsirkin" <mst@xxxxxxxxxx>

commit 3ea79249e81e5ed051f2e6480cbde896d99046e8 upstream.

Upon TUNSETSNDBUF, macvtap reads the requested sndbuf size into
a local variable u.
commit 39ec7de7092b ("macvtap: fix uninitialized access on
TUNSETIFF") changed its type to u16 (which is the right thing to
do for all other macvtap ioctls), breaking all values > 64k.

The value of TUNSETSNDBUF is actually a signed 32 bit integer, so
the right thing to do is to read it into an int.

Cc: David S. Miller <davem@xxxxxxxxxxxxx>
Fixes: 39ec7de7092b ("macvtap: fix uninitialized access on TUNSETIFF")
Reported-by: Mark A. Peloquin
Bisected-by: Matthew Rosato <mjrosato@xxxxxxxxxxxxxxxxxx>
Reported-by: Christian Borntraeger <borntraeger@xxxxxxxxxx>
Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
Tested-by: Matthew Rosato <mjrosato@xxxxxxxxxxxxxxxxxx>
Acked-by: Christian Borntraeger <borntraeger@xxxxxxxxxx>
Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
---
drivers/net/macvtap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -1051,10 +1051,10 @@ static long macvtap_ioctl(struct file *f
return 0;

case TUNSETSNDBUF:
- if (get_user(u, up))
+ if (get_user(s, sp))
return -EFAULT;

- q->sk.sk_sndbuf = u;
+ q->sk.sk_sndbuf = s;
return 0;

case TUNGETVNETHDRSZ: