diff options
Diffstat (limited to 'fs/compat_ioctl.c')
-rw-r--r-- | fs/compat_ioctl.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index b9e3357bcc2e..9c3fd07f35e0 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -319,22 +319,21 @@ struct ifconf32 { | |||
319 | 319 | ||
320 | static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg) | 320 | static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg) |
321 | { | 321 | { |
322 | struct net_device *dev; | 322 | struct ifreq __user *uifr; |
323 | struct ifreq32 ifr32; | ||
324 | int err; | 323 | int err; |
325 | 324 | ||
326 | if (copy_from_user(&ifr32, compat_ptr(arg), sizeof(ifr32))) | 325 | uifr = compat_alloc_user_space(sizeof(struct ifreq)); |
326 | if (copy_in_user(uifr, compat_ptr(arg), sizeof(struct ifreq32))); | ||
327 | return -EFAULT; | 327 | return -EFAULT; |
328 | 328 | ||
329 | dev = dev_get_by_index(ifr32.ifr_ifindex); | 329 | err = sys_ioctl(fd, SIOCGIFNAME, (unsigned long)uifr); |
330 | if (!dev) | 330 | if (err) |
331 | return -ENODEV; | 331 | return err; |
332 | 332 | ||
333 | strlcpy(ifr32.ifr_name, dev->name, sizeof(ifr32.ifr_name)); | 333 | if (copy_in_user(compat_ptr(arg), uifr, sizeof(struct ifreq32))) |
334 | dev_put(dev); | 334 | return -EFAULT; |
335 | 335 | ||
336 | err = copy_to_user(compat_ptr(arg), &ifr32, sizeof(ifr32)); | 336 | return 0; |
337 | return (err ? -EFAULT : 0); | ||
338 | } | 337 | } |
339 | 338 | ||
340 | static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg) | 339 | static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg) |