Skip to content

Commit 32da477

Browse files
ebiedermDavid S. Miller
authored andcommitted
[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>
1 parent 890d52d commit 32da477

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

‎fs/compat_ioctl.c‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -324,22 +324,21 @@ struct ifconf32 {
324324

325325
static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg)
326326
{
327-
struct net_device *dev;
328-
struct ifreq32 ifr32;
327+
struct ifreq __user *uifr;
329328
int err;
330329

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)));
332332
return -EFAULT;
333333

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;
337337

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;
343342
}
344343

345344
static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg)

0 commit comments

Comments
 (0)