Skip to content

Commit

Permalink
macvtap: fix uninitialized access on TUNSETIFF
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael S. Tsirkin authored and David S. Miller committed Dec 16, 2014
1 parent c286bba commit 39ec7de
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/net/macvtap.c
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit 39ec7de

Please sign in to comment.