aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2018-08-16 21:37:56 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2018-09-10 12:41:06 -0400
commit89c0c24b4fa137cc846f50b3595f42e5f19da13b (patch)
tree4811f3807ddf58b707b9f1034df1868e9d994dd1
parentcc04f6e2421ad0da0f44f0fbf8e8259f3966f2a1 (diff)
cmtp: fix compat_ioctl
Use compat_ptr(). And don't mess with fs/compat_ioctl.c Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/compat_ioctl.c9
-rw-r--r--net/bluetooth/cmtp/sock.c19
2 files changed, 12 insertions, 16 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index b183496d1fa8..4e049f460091 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -534,11 +534,6 @@ static int mt_ioctl_trans(struct file *file,
534#define HCIUARTSETFLAGS _IOW('U', 203, int) 534#define HCIUARTSETFLAGS _IOW('U', 203, int)
535#define HCIUARTGETFLAGS _IOR('U', 204, int) 535#define HCIUARTGETFLAGS _IOR('U', 204, int)
536 536
537#define CMTPCONNADD _IOW('C', 200, int)
538#define CMTPCONNDEL _IOW('C', 201, int)
539#define CMTPGETCONNLIST _IOR('C', 210, int)
540#define CMTPGETCONNINFO _IOR('C', 211, int)
541
542#define HIDPCONNADD _IOW('H', 200, int) 537#define HIDPCONNADD _IOW('H', 200, int)
543#define HIDPCONNDEL _IOW('H', 201, int) 538#define HIDPCONNDEL _IOW('H', 201, int)
544#define HIDPGETCONNLIST _IOR('H', 210, int) 539#define HIDPGETCONNLIST _IOR('H', 210, int)
@@ -1090,10 +1085,6 @@ COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
1090COMPATIBLE_IOCTL(RFCOMMGETDEVLIST) 1085COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
1091COMPATIBLE_IOCTL(RFCOMMGETDEVINFO) 1086COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
1092COMPATIBLE_IOCTL(RFCOMMSTEALDLC) 1087COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
1093COMPATIBLE_IOCTL(CMTPCONNADD)
1094COMPATIBLE_IOCTL(CMTPCONNDEL)
1095COMPATIBLE_IOCTL(CMTPGETCONNLIST)
1096COMPATIBLE_IOCTL(CMTPGETCONNINFO)
1097COMPATIBLE_IOCTL(HIDPCONNADD) 1088COMPATIBLE_IOCTL(HIDPCONNADD)
1098COMPATIBLE_IOCTL(HIDPCONNDEL) 1089COMPATIBLE_IOCTL(HIDPCONNDEL)
1099COMPATIBLE_IOCTL(HIDPGETCONNLIST) 1090COMPATIBLE_IOCTL(HIDPGETCONNLIST)
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c
index e08f28fadd65..defdd4871919 100644
--- a/net/bluetooth/cmtp/sock.c
+++ b/net/bluetooth/cmtp/sock.c
@@ -63,17 +63,16 @@ static int cmtp_sock_release(struct socket *sock)
63 return 0; 63 return 0;
64} 64}
65 65
66static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) 66static int do_cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, void __user *argp)
67{ 67{
68 struct cmtp_connadd_req ca; 68 struct cmtp_connadd_req ca;
69 struct cmtp_conndel_req cd; 69 struct cmtp_conndel_req cd;
70 struct cmtp_connlist_req cl; 70 struct cmtp_connlist_req cl;
71 struct cmtp_conninfo ci; 71 struct cmtp_conninfo ci;
72 struct socket *nsock; 72 struct socket *nsock;
73 void __user *argp = (void __user *)arg;
74 int err; 73 int err;
75 74
76 BT_DBG("cmd %x arg %lx", cmd, arg); 75 BT_DBG("cmd %x arg %p", cmd, argp);
77 76
78 switch (cmd) { 77 switch (cmd) {
79 case CMTPCONNADD: 78 case CMTPCONNADD:
@@ -137,16 +136,22 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
137 return -EINVAL; 136 return -EINVAL;
138} 137}
139 138
139static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
140{
141 return do_cmtp_sock_ioctl(sock, cmd, (void __user *)arg);
142}
143
140#ifdef CONFIG_COMPAT 144#ifdef CONFIG_COMPAT
141static int cmtp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) 145static int cmtp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
142{ 146{
147 void __user *argp = compat_ptr(arg);
143 if (cmd == CMTPGETCONNLIST) { 148 if (cmd == CMTPGETCONNLIST) {
144 struct cmtp_connlist_req cl; 149 struct cmtp_connlist_req cl;
150 u32 __user *p = argp;
145 u32 uci; 151 u32 uci;
146 int err; 152 int err;
147 153
148 if (get_user(cl.cnum, (u32 __user *) arg) || 154 if (get_user(cl.cnum, p) || get_user(uci, p + 1))
149 get_user(uci, (u32 __user *) (arg + 4)))
150 return -EFAULT; 155 return -EFAULT;
151 156
152 cl.ci = compat_ptr(uci); 157 cl.ci = compat_ptr(uci);
@@ -156,13 +161,13 @@ static int cmtp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigne
156 161
157 err = cmtp_get_connlist(&cl); 162 err = cmtp_get_connlist(&cl);
158 163
159 if (!err && put_user(cl.cnum, (u32 __user *) arg)) 164 if (!err && put_user(cl.cnum, p))
160 err = -EFAULT; 165 err = -EFAULT;
161 166
162 return err; 167 return err;
163 } 168 }
164 169
165 return cmtp_sock_ioctl(sock, cmd, arg); 170 return do_cmtp_sock_ioctl(sock, cmd, argp);
166} 171}
167#endif 172#endif
168 173