Commit 89bbfc95 authored by Shaun Pereira's avatar Shaun Pereira Committed by David S. Miller

[NET]: allow 32 bit socket ioctl in 64 bit kernel

Since the register_ioctl32_conversion() patch in the kernel is now obsolete,
provide another method to allow 32 bit user space ioctls to reach the kernel.
Signed-off-by: default avatarShaun Pereira <spereira@tusc.com.au>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 67b52e55
...@@ -143,6 +143,8 @@ struct proto_ops { ...@@ -143,6 +143,8 @@ struct proto_ops {
struct poll_table_struct *wait); struct poll_table_struct *wait);
int (*ioctl) (struct socket *sock, unsigned int cmd, int (*ioctl) (struct socket *sock, unsigned int cmd,
unsigned long arg); unsigned long arg);
int (*compat_ioctl) (struct socket *sock, unsigned int cmd,
unsigned long arg);
int (*listen) (struct socket *sock, int len); int (*listen) (struct socket *sock, int len);
int (*shutdown) (struct socket *sock, int flags); int (*shutdown) (struct socket *sock, int flags);
int (*setsockopt)(struct socket *sock, int level, int (*setsockopt)(struct socket *sock, int level,
...@@ -251,6 +253,8 @@ SOCKCALL_UWRAP(name, poll, (struct file *file, struct socket *sock, struct poll_ ...@@ -251,6 +253,8 @@ SOCKCALL_UWRAP(name, poll, (struct file *file, struct socket *sock, struct poll_
(file, sock, wait)) \ (file, sock, wait)) \
SOCKCALL_WRAP(name, ioctl, (struct socket *sock, unsigned int cmd, \ SOCKCALL_WRAP(name, ioctl, (struct socket *sock, unsigned int cmd, \
unsigned long arg), (sock, cmd, arg)) \ unsigned long arg), (sock, cmd, arg)) \
SOCKCALL_WRAP(name, compat_ioctl, (struct socket *sock, unsigned int cmd, \
unsigned long arg), (sock, cmd, arg)) \
SOCKCALL_WRAP(name, listen, (struct socket *sock, int len), (sock, len)) \ SOCKCALL_WRAP(name, listen, (struct socket *sock, int len), (sock, len)) \
SOCKCALL_WRAP(name, shutdown, (struct socket *sock, int flags), (sock, flags)) \ SOCKCALL_WRAP(name, shutdown, (struct socket *sock, int flags), (sock, flags)) \
SOCKCALL_WRAP(name, setsockopt, (struct socket *sock, int level, int optname, \ SOCKCALL_WRAP(name, setsockopt, (struct socket *sock, int level, int optname, \
...@@ -275,6 +279,7 @@ static const struct proto_ops name##_ops = { \ ...@@ -275,6 +279,7 @@ static const struct proto_ops name##_ops = { \
.getname = __lock_##name##_getname, \ .getname = __lock_##name##_getname, \
.poll = __lock_##name##_poll, \ .poll = __lock_##name##_poll, \
.ioctl = __lock_##name##_ioctl, \ .ioctl = __lock_##name##_ioctl, \
.compat_ioctl = __lock_##name##_compat_ioctl, \
.listen = __lock_##name##_listen, \ .listen = __lock_##name##_listen, \
.shutdown = __lock_##name##_shutdown, \ .shutdown = __lock_##name##_shutdown, \
.setsockopt = __lock_##name##_setsockopt, \ .setsockopt = __lock_##name##_setsockopt, \
...@@ -283,6 +288,7 @@ static const struct proto_ops name##_ops = { \ ...@@ -283,6 +288,7 @@ static const struct proto_ops name##_ops = { \
.recvmsg = __lock_##name##_recvmsg, \ .recvmsg = __lock_##name##_recvmsg, \
.mmap = __lock_##name##_mmap, \ .mmap = __lock_##name##_mmap, \
}; };
#endif #endif
#define MODULE_ALIAS_NETPROTO(proto) \ #define MODULE_ALIAS_NETPROTO(proto) \
......
...@@ -107,6 +107,10 @@ static unsigned int sock_poll(struct file *file, ...@@ -107,6 +107,10 @@ static unsigned int sock_poll(struct file *file,
struct poll_table_struct *wait); struct poll_table_struct *wait);
static long sock_ioctl(struct file *file, static long sock_ioctl(struct file *file,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
#ifdef CONFIG_COMPAT
static long compat_sock_ioctl(struct file *file,
unsigned int cmd, unsigned long arg);
#endif
static int sock_fasync(int fd, struct file *filp, int on); static int sock_fasync(int fd, struct file *filp, int on);
static ssize_t sock_readv(struct file *file, const struct iovec *vector, static ssize_t sock_readv(struct file *file, const struct iovec *vector,
unsigned long count, loff_t *ppos); unsigned long count, loff_t *ppos);
...@@ -128,6 +132,9 @@ static struct file_operations socket_file_ops = { ...@@ -128,6 +132,9 @@ static struct file_operations socket_file_ops = {
.aio_write = sock_aio_write, .aio_write = sock_aio_write,
.poll = sock_poll, .poll = sock_poll,
.unlocked_ioctl = sock_ioctl, .unlocked_ioctl = sock_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = compat_sock_ioctl,
#endif
.mmap = sock_mmap, .mmap = sock_mmap,
.open = sock_no_open, /* special open code to disallow open via /proc */ .open = sock_no_open, /* special open code to disallow open via /proc */
.release = sock_close, .release = sock_close,
...@@ -2136,6 +2143,20 @@ void socket_seq_show(struct seq_file *seq) ...@@ -2136,6 +2143,20 @@ void socket_seq_show(struct seq_file *seq)
} }
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
#ifdef CONFIG_COMPAT
static long compat_sock_ioctl(struct file *file, unsigned cmd,
unsigned long arg)
{
struct socket *sock = file->private_data;
int ret = -ENOIOCTLCMD;
if (sock->ops->compat_ioctl)
ret = sock->ops->compat_ioctl(sock, cmd, arg);
return ret;
}
#endif
/* ABI emulation layers need these two */ /* ABI emulation layers need these two */
EXPORT_SYMBOL(move_addr_to_kernel); EXPORT_SYMBOL(move_addr_to_kernel);
EXPORT_SYMBOL(move_addr_to_user); EXPORT_SYMBOL(move_addr_to_user);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment