Commit 32da477a5bfe96b6dfc8960e0d22d89ca09fd10a
Committed by
David S. Miller
1 parent
890d52d3f1
Exists in
master
and in
4 other branches
[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: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 10 additions and 11 deletions Side-by-side Diff
fs/compat_ioctl.c
... | ... | @@ -324,22 +324,21 @@ |
324 | 324 | |
325 | 325 | static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg) |
326 | 326 | { |
327 | - struct net_device *dev; | |
328 | - struct ifreq32 ifr32; | |
327 | + struct ifreq __user *uifr; | |
329 | 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 | 332 | return -EFAULT; |
333 | 333 | |
334 | - dev = dev_get_by_index(ifr32.ifr_ifindex); | |
335 | - if (!dev) | |
336 | - return -ENODEV; | |
334 | + err = sys_ioctl(fd, SIOCGIFNAME, (unsigned long)uifr); | |
335 | + if (err) | |
336 | + return err; | |
337 | 337 | |
338 | - strlcpy(ifr32.ifr_name, dev->name, sizeof(ifr32.ifr_name)); | |
339 | - dev_put(dev); | |
340 | - | |
341 | - err = copy_to_user(compat_ptr(arg), &ifr32, sizeof(ifr32)); | |
342 | - return (err ? -EFAULT : 0); | |
338 | + if (copy_in_user(compat_ptr(arg), uifr, sizeof(struct ifreq32))) | |
339 | + return -EFAULT; | |
340 | + | |
341 | + return 0; | |
343 | 342 | } |
344 | 343 | |
345 | 344 | static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg) |