Commit 32da477a authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

[NET]: Don't implement dev_ifname32 inline

The current implementation of dev_ifname makes maintenance difficult
because updates to the implementation of the ioctl have to made in two
places.  So this patch updates dev_ifname32 to do a classic 32/64
structure conversion and call sys_ioctl like the rest of the
compat calls do.
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 890d52d3
...@@ -324,22 +324,21 @@ struct ifconf32 { ...@@ -324,22 +324,21 @@ struct ifconf32 {
static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg) static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
{ {
struct net_device *dev; struct ifreq __user *uifr;
struct ifreq32 ifr32;
int err; int err;
if (copy_from_user(&ifr32, compat_ptr(arg), sizeof(ifr32))) uifr = compat_alloc_user_space(sizeof(struct ifreq));
if (copy_in_user(uifr, compat_ptr(arg), sizeof(struct ifreq32)));
return -EFAULT; return -EFAULT;
dev = dev_get_by_index(ifr32.ifr_ifindex); err = sys_ioctl(fd, SIOCGIFNAME, (unsigned long)uifr);
if (!dev) if (err)
return -ENODEV; return err;
strlcpy(ifr32.ifr_name, dev->name, sizeof(ifr32.ifr_name)); if (copy_in_user(compat_ptr(arg), uifr, sizeof(struct ifreq32)))
dev_put(dev); return -EFAULT;
err = copy_to_user(compat_ptr(arg), &ifr32, sizeof(ifr32)); return 0;
return (err ? -EFAULT : 0);
} }
static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg) static int dev_ifconf(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