summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-12-16 16:04:56 +0300
committerDavid S. Miller <davem@davemloft.net>2014-12-16 19:19:41 +0300
commit39ec7de7092ba9789f211d112a66bd19d4cb5d36 (patch)
treedfa9725a4c54e900c9a60999f29b0f65b72f96fd /drivers/net
parentc286bbaf4f56958db2591146145e248c7b9021c5 (diff)
downloadlinux-39ec7de7092ba9789f211d112a66bd19d4cb5d36.tar.xz
macvtap: fix uninitialized access on TUNSETIFF
flags field in ifreq is only 16 bit wide, but we read it as a 32 bit value. If userspace doesn't zero-initialize unused fields, this will lead to failures. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/macvtap.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 60f7ee5fafbe..80fdb82352fa 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -999,7 +999,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
void __user *argp = (void __user *)arg;
struct ifreq __user *ifr = argp;
unsigned int __user *up = argp;
- unsigned int u;
+ unsigned short u;
int __user *sp = argp;
int s;
int ret;
@@ -1014,7 +1014,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
if ((u & ~MACVTAP_FEATURES) != (IFF_NO_PI | IFF_TAP))
ret = -EINVAL;
else
- q->flags = u;
+ q->flags = (q->flags & ~MACVTAP_FEATURES) | u;
return ret;
@@ -1027,8 +1027,9 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
}
ret = 0;
+ u = q->flags;
if (copy_to_user(&ifr->ifr_name, vlan->dev->name, IFNAMSIZ) ||
- put_user(q->flags, &ifr->ifr_flags))
+ put_user(u, &ifr->ifr_flags))
ret = -EFAULT;
macvtap_put_vlan(vlan);
rtnl_unlock();