Commit 0141a137 authored by Arun Sharma's avatar Arun Sharma Committed by David Mosberger

[COMPAT]: Fix net bonding driver ioctl translations.

parent 4655e5f9
...@@ -576,54 +576,45 @@ static int ethtool_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) ...@@ -576,54 +576,45 @@ static int ethtool_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
static int bond_ioctl(unsigned long fd, unsigned int cmd, unsigned long arg) static int bond_ioctl(unsigned long fd, unsigned int cmd, unsigned long arg)
{ {
struct ifreq ifr; struct ifreq kifr;
struct ifreq *uifr;
struct ifreq32 *ifr32 = (struct ifreq32 *) arg;
mm_segment_t old_fs; mm_segment_t old_fs;
int err, len; int err;
u32 data; u32 data;
void *datap;
if (copy_from_user(&ifr, (struct ifreq32 *)arg, sizeof(struct ifreq32)))
return -EFAULT;
ifr.ifr_data = (__kernel_caddr_t)get_zeroed_page(GFP_KERNEL);
if (!ifr.ifr_data)
return -EAGAIN;
switch (cmd) { switch (cmd) {
case SIOCBONDENSLAVE: case SIOCBONDENSLAVE:
case SIOCBONDRELEASE: case SIOCBONDRELEASE:
case SIOCBONDSETHWADDR: case SIOCBONDSETHWADDR:
case SIOCBONDCHANGEACTIVE: case SIOCBONDCHANGEACTIVE:
len = IFNAMSIZ * sizeof(char); if (copy_from_user(&kifr, ifr32, sizeof(struct ifreq32)))
break; return -EFAULT;
case SIOCBONDSLAVEINFOQUERY:
len = sizeof(struct ifslave);
break;
case SIOCBONDINFOQUERY:
len = sizeof(struct ifbond);
break;
default:
err = -EINVAL;
goto out;
};
__get_user(data, &(((struct ifreq32 *)arg)->ifr_ifru.ifru_data));
if (copy_from_user(ifr.ifr_data, compat_ptr(data), len)) {
err = -EFAULT;
goto out;
}
old_fs = get_fs(); old_fs = get_fs();
set_fs (KERNEL_DS); set_fs (KERNEL_DS);
err = sys_ioctl (fd, cmd, (unsigned long)&ifr); err = sys_ioctl (fd, cmd, (unsigned long)&kifr);
set_fs (old_fs); set_fs (old_fs);
if (!err) {
len = copy_to_user(compat_ptr(data), ifr.ifr_data, len);
if (len)
err = -EFAULT;
}
out:
free_page((unsigned long)ifr.ifr_data);
return err; return err;
case SIOCBONDSLAVEINFOQUERY:
case SIOCBONDINFOQUERY:
uifr = compat_alloc_user_space(sizeof(*uifr));
if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
return -EFAULT;
if (get_user(data, &ifr32->ifr_ifru.ifru_data))
return -EFAULT;
datap = compat_ptr(data);
if (put_user(datap, &uifr->ifr_ifru.ifru_data))
return -EFAULT;
return sys_ioctl (fd, cmd, (unsigned long)uifr);
default:
return -EINVAL;
};
} }
int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment