Skip to contentSkip to conversation

: Dispatch and handle compat ioctls entirely in net/wireless/wext.c

PATCH In review David Miller 1 participant 1 message Dec 22, 2007

Subsystems (5)
lore
Share & tools
lore

David Miller

author maintainer
#0 lore raw

PATCH 9/12 : Dispatch and handle compat ioctls entirely in net/wireless/wext.c

[WEXT]: Dispatch and handle compat ioctls entirely in net/wireless/wext.c

Next we can kill the hacks in fs/compat_ioctl.c and also dispatch compat ioctls down into the driver and 80211 protocol helper layers in order to handle iw_point objects embedded in stream replies which need to be translated.

---
 fs/compat_ioctl.c        |    6 ---
 include/linux/wireless.h |    9 ++++
 include/net/wext.h       |    7 +++
 net/socket.c             |   10 ++++
 net/wireless/wext.c      |  104 ++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 130 insertions(+), 6 deletions(-)
fs/compat_ioctl.c +0 -6
index e8b7c3a..e98e950 100644
@@ -1756,12 +1756,6 @@ static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long a
 	return sys_ioctl(fd, cmd, (unsigned long)tdata);
 }
 
-struct compat_iw_point {
-	compat_caddr_t pointer;
-	__u16 length;
-	__u16 flags;
-};
-
 static int do_wireless_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
 {
 	struct iwreq __user *iwr;
include/linux/wireless.h +9 -0
index 0987aa7..2088524 100644
@@ -76,6 +76,7 @@
 #include <linux/types.h>		/* for "caddr_t" et al		*/
 #include <linux/socket.h>		/* for "struct sockaddr" et al	*/
 #include <linux/if.h>			/* for IFNAMSIZ and co... */
+#include <linux/compat.h>
 #endif	/* __KERNEL__ */
 
 /***************************** VERSION *****************************/
@@ -669,6 +670,14 @@ struct	iw_point
   __u16		flags;		/* Optional params */
 };
 
+#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
+struct compat_iw_point {
+	compat_caddr_t pointer;
+	__u16 length;
+	__u16 flags;
+};
+#endif
+
 /*
  *	A frequency
  *	For numbers lower than 10^9, we encode the number in 'm' and
include/net/wext.h +7 -0
index 80b31d8..6d76a39 100644
@@ -12,6 +12,8 @@ extern int wext_proc_init(struct net *net);
 extern void wext_proc_exit(struct net *net);
 extern int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
 			     void __user *arg);
+extern int compat_wext_handle_ioctl(struct net *net, unsigned int cmd,
+				    unsigned long arg);
 #else
 static inline int wext_proc_init(struct net *net)
 {
@@ -26,6 +28,11 @@ static inline int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned
 {
 	return -EINVAL;
 }
+static inline int compat_wext_handle_ioctl(struct net *net, unsigned int cmd,
+					   unsigned long arg)
+{
+	return -EINVAL;
+}
 #endif
 
 #endif /* __NET_WEXT_H */
net/socket.c +10 -0
index 74784df..475f08f 100644
@@ -90,6 +90,7 @@
 #include <asm/unistd.h>
 
 #include <net/compat.h>
+#include <net/wext.h>
 
 #include <net/sock.h>
 #include <linux/netfilter.h>
@@ -2207,10 +2208,19 @@ static long compat_sock_ioctl(struct file *file, unsigned cmd,
 {
 	struct socket *sock = file->private_data;
 	int ret = -ENOIOCTLCMD;
+	struct sock *sk;
+	struct net *net;
+
+	sk = sock->sk;
+	net = sk->sk_net;
 
 	if (sock->ops->compat_ioctl)
 		ret = sock->ops->compat_ioctl(sock, cmd, arg);
 
+	if (ret == -ENOIOCTLCMD &&
+	    (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST))
+		ret = compat_wext_handle_ioctl(net, cmd, arg);
+
 	return ret;
 }
 #endif
net/wireless/wext.c +104 -0

110 lines not on this page · raw message

Signature · 1 line
1.5.4.rc1