aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/compat_ioctl.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 37310b0e8107..d917e4a26a43 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -324,22 +324,21 @@ struct ifconf32 {
324 324
325static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg) 325static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
326{ 326{
327 struct net_device *dev; 327 struct ifreq __user *uifr;
328 struct ifreq32 ifr32;
329 int err; 328 int err;
330 329
331 if (copy_from_user(&ifr32, compat_ptr(arg), sizeof(ifr32))) 330 uifr = compat_alloc_user_space(sizeof(struct ifreq));
331 if (copy_in_user(uifr, compat_ptr(arg), sizeof(struct ifreq32)));
332 return -EFAULT; 332 return -EFAULT;
333 333
334 dev = dev_get_by_index(ifr32.ifr_ifindex); 334 err = sys_ioctl(fd, SIOCGIFNAME, (unsigned long)uifr);
335 if (!dev) 335 if (err)
336 return -ENODEV; 336 return err;
337 337
338 strlcpy(ifr32.ifr_name, dev->name, sizeof(ifr32.ifr_name)); 338 if (copy_in_user(compat_ptr(arg), uifr, sizeof(struct ifreq32)))
339 dev_put(dev); 339 return -EFAULT;
340 340
341 err = copy_to_user(compat_ptr(arg), &ifr32, sizeof(ifr32)); 341 return 0;
342 return (err ? -EFAULT : 0);
343} 342}
344 343
345static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg) 344static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)