[PATCH 1/6] x25: Allow 32 bit socket ioctl in 64 bit kernel



Hi

The following patch provides 32 bit userland ioctl support for modular
(x.25 type) socket ioctls in a 64 bit kernel. Since the the
register_ioctl32_conversion() is now obsolete, this patch provides a
mechanism to allow 32 bit user space ioctls to reach the kernel.

Signed-off-by:Shaun Pereira <spereira@xxxxxxxxxxx>
Acked-by: Arnd Bergmann <arnd@xxxxxxxx>

diff -uprN -X dontdiff linux-2.6.16-rc3-vanilla/include/linux/net.h
linux-2.6.16-rc3/include/linux/net.h
--- linux-2.6.16-rc3-vanilla/include/linux/net.h 2006-02-15
10:58:02.000000000 +1100
+++ linux-2.6.16-rc3/include/linux/net.h 2006-02-15 11:02:24.000000000
+1100
@@ -143,6 +143,8 @@ struct proto_ops {
struct poll_table_struct *wait);
int (*ioctl) (struct socket *sock, unsigned int cmd,
unsigned long arg);
+ int (*compat_ioctl) (struct socket *sock, unsigned int cmd,
+ unsigned long arg);
int (*listen) (struct socket *sock, int len);
int (*shutdown) (struct socket *sock, int flags);
int (*setsockopt)(struct socket *sock, int level,
@@ -247,6 +249,8 @@ SOCKCALL_UWRAP(name, poll, (struct file
(file, sock, wait)) \
SOCKCALL_WRAP(name, ioctl, (struct socket *sock, unsigned int cmd, \
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, shutdown, (struct socket *sock, int flags), (sock,
flags)) \
SOCKCALL_WRAP(name, setsockopt, (struct socket *sock, int level, int
optname, \
@@ -271,6 +275,7 @@ static const struct proto_ops name##_ops
.getname = __lock_##name##_getname, \
.poll = __lock_##name##_poll, \
.ioctl = __lock_##name##_ioctl, \
+ .compat_ioctl = __lock_##name##_compat_ioctl, \
.listen = __lock_##name##_listen, \
.shutdown = __lock_##name##_shutdown, \
.setsockopt = __lock_##name##_setsockopt, \
@@ -279,6 +284,7 @@ static const struct proto_ops name##_ops
.recvmsg = __lock_##name##_recvmsg, \
.mmap = __lock_##name##_mmap, \
};
+
#endif

#define MODULE_ALIAS_NETPROTO(proto) \
diff -uprN -X dontdiff linux-2.6.16-rc3-vanilla/net/socket.c
linux-2.6.16-rc3/net/socket.c
--- linux-2.6.16-rc3-vanilla/net/socket.c 2006-02-15 10:58:03.000000000
+1100
+++ linux-2.6.16-rc3/net/socket.c 2006-02-15 11:02:24.000000000 +1100
@@ -109,6 +109,10 @@ static unsigned int sock_poll(struct fil
struct poll_table_struct *wait);
static long sock_ioctl(struct file *file,
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 ssize_t sock_readv(struct file *file, const struct iovec
*vector,
unsigned long count, loff_t *ppos);
@@ -130,6 +134,9 @@ static struct file_operations socket_fil
.aio_write = sock_aio_write,
.poll = sock_poll,
.unlocked_ioctl = sock_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = compat_sock_ioctl,
+#endif
.mmap = sock_mmap,
.open = sock_no_open, /* special open code to disallow open via /proc
*/
.release = sock_close,
@@ -2089,6 +2096,20 @@ void socket_seq_show(struct seq_file *se
}
#endif /* CONFIG_PROC_FS */

+#ifdef CONFIG_COMPAT
+static long compat_sock_ioctl(struct file *file, unsigned cmd, unsigned
long arg)
+{
+ struct socket *sock;
+ 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 */
EXPORT_SYMBOL(move_addr_to_kernel);
EXPORT_SYMBOL(move_addr_to_user);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • [PATCH] Delete superfluous source file "net/wanrouter/af_wanpipe.c".
    ... 2000 Nenad Corbic o Fixed the corrupt sock lcn problem. ... -/* SECURE SOCKET IMPLEMENTATION ... * routine in the wanpipe driver. ... -static void * dbg_kmalloc(unsigned int size, int prio, int line) { ...
    (Linux-Kernel)
  • Re: freeing port - winsock
    ... When I create and destroy many sockets without specifying the local port to bind, It seems that this local port is not free after using the function closesocket. ... It's goal is to create a socket, connect to a remote server on port 80, close the socket and to loop on these actions. ... int host ... SOCKET sock = INVALID_SOCKET; ...
    (comp.programming)
  • [2.6 patch] net/packet/af_packet.c: make some code static
    ... /* Private packet socket structures. ... +static void packet_sock_destruct(struct sock *sk) ... +static struct proto_ops packet_ops_spkt; ... -int packet_getsockopt(struct socket *sock, int level, int optname, ...
    (Linux-Kernel)
  • Re: maximum timeout on socket connection
    ... > operations on the socket. ... * returns zero on success, ETIME on timeout, errno on connect failure. ... int connectex ... socket_set_nonblocking(int sock, bool mode) ...
    (comp.unix.programmer)
  • Re: Linux 2.6.29.4
    ... static int is_efer_nx ... if (ret) ... struct ftdi_private { ... the specific security attributes of the socket ...
    (Linux-Kernel)