Skip to content

Commit 89c0c24

Browse files
author
Al Viro
committed
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>
1 parent cc04f6e commit 89c0c24

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

‎fs/compat_ioctl.c‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,6 @@ static int mt_ioctl_trans(struct file *file,
534534
#define HCIUARTSETFLAGS _IOW('U', 203, int)
535535
#define HCIUARTGETFLAGS _IOR('U', 204, int)
536536

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-
542537
#define HIDPCONNADD _IOW('H', 200, int)
543538
#define HIDPCONNDEL _IOW('H', 201, int)
544539
#define HIDPGETCONNLIST _IOR('H', 210, int)
@@ -1090,10 +1085,6 @@ COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
10901085
COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
10911086
COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
10921087
COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
1093-
COMPATIBLE_IOCTL(CMTPCONNADD)
1094-
COMPATIBLE_IOCTL(CMTPCONNDEL)
1095-
COMPATIBLE_IOCTL(CMTPGETCONNLIST)
1096-
COMPATIBLE_IOCTL(CMTPGETCONNINFO)
10971088
COMPATIBLE_IOCTL(HIDPCONNADD)
10981089
COMPATIBLE_IOCTL(HIDPCONNDEL)
10991090
COMPATIBLE_IOCTL(HIDPGETCONNLIST)

‎net/bluetooth/cmtp/sock.c‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,16 @@ static int cmtp_sock_release(struct socket *sock)
6363
return 0;
6464
}
6565

66-
static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
66+
static int do_cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, void __user *argp)
6767
{
6868
struct cmtp_connadd_req ca;
6969
struct cmtp_conndel_req cd;
7070
struct cmtp_connlist_req cl;
7171
struct cmtp_conninfo ci;
7272
struct socket *nsock;
73-
void __user *argp = (void __user *)arg;
7473
int err;
7574

76-
BT_DBG("cmd %x arg %lx", cmd, arg);
75+
BT_DBG("cmd %x arg %p", cmd, argp);
7776

7877
switch (cmd) {
7978
case CMTPCONNADD:
@@ -137,16 +136,22 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
137136
return -EINVAL;
138137
}
139138

139+
static 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+
140144
#ifdef CONFIG_COMPAT
141145
static int cmtp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
142146
{
147+
void __user *argp = compat_ptr(arg);
143148
if (cmd == CMTPGETCONNLIST) {
144149
struct cmtp_connlist_req cl;
150+
u32 __user *p = argp;
145151
u32 uci;
146152
int err;
147153

148-
if (get_user(cl.cnum, (u32 __user *) arg) ||
149-
get_user(uci, (u32 __user *) (arg + 4)))
154+
if (get_user(cl.cnum, p) || get_user(uci, p + 1))
150155
return -EFAULT;
151156

152157
cl.ci = compat_ptr(uci);
@@ -156,13 +161,13 @@ static int cmtp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigne
156161

157162
err = cmtp_get_connlist(&cl);
158163

159-
if (!err && put_user(cl.cnum, (u32 __user *) arg))
164+
if (!err && put_user(cl.cnum, p))
160165
err = -EFAULT;
161166

162167
return err;
163168
}
164169

165-
return cmtp_sock_ioctl(sock, cmd, arg);
170+
return do_cmtp_sock_ioctl(sock, cmd, argp);
166171
}
167172
#endif
168173

0 commit comments

Comments
 (0)