net, compat_ioctl: handle socket ioctl abuses in tty drivers
Slip and a few other drivers use the same ioctl numbers on tty devices that are normally meant for sockets. This causes problems with our compat_ioctl handling that tries to convert the data structures in a different format. Fortunately, these five drivers all use 32 bit compatible data structures in the ioctl numbers, so we can just add a trivial compat_ioctl conversion function to each of them. SIOCSIFENCAP and SIOCGIFENCAP do not need to live in fs/compat_ioctl.c after this any more, and they are not used on any sockets. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Этот коммит содержится в:

коммит произвёл
David S. Miller

родитель
50857e2a59
Коммит
9646e7ce3d
@@ -33,6 +33,7 @@
|
||||
#include <linux/lapb.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <linux/compat.h>
|
||||
#include "x25_asy.h"
|
||||
|
||||
#include <net/x25device.h>
|
||||
@@ -705,6 +706,21 @@ static int x25_asy_ioctl(struct tty_struct *tty, struct file *file,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
static long x25_asy_compat_ioctl(struct tty_struct *tty, struct file *file,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
switch (cmd) {
|
||||
case SIOCGIFNAME:
|
||||
case SIOCSIFHWADDR:
|
||||
return x25_asy_ioctl(tty, file, cmd,
|
||||
(unsigned long)compat_ptr(arg));
|
||||
}
|
||||
|
||||
return -ENOIOCTLCMD;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int x25_asy_open_dev(struct net_device *dev)
|
||||
{
|
||||
struct x25_asy *sl = netdev_priv(dev);
|
||||
@@ -754,6 +770,9 @@ static struct tty_ldisc_ops x25_ldisc = {
|
||||
.open = x25_asy_open_tty,
|
||||
.close = x25_asy_close_tty,
|
||||
.ioctl = x25_asy_ioctl,
|
||||
#ifdef CONFIG_COMPAT
|
||||
.compat_ioctl = x25_asy_compat_ioctl,
|
||||
#endif
|
||||
.receive_buf = x25_asy_receive_buf,
|
||||
.write_wakeup = x25_asy_write_wakeup,
|
||||
};
|
||||
|
Ссылка в новой задаче
Block a user