aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-06-27 17:46:06 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-06-29 18:17:52 -0400
commitcc1a7c4bae28215d042fb9f00dcb77dd65abafdf (patch)
treeeca5e1a56ff3e344048b5a50f72f9b3bf5e488a5
parent30138384dae74cdd5694615c098a19af984a3dda (diff)
usbdevfs: get rid of field-by-field copyin
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--drivers/usb/core/devio.c48
1 files changed, 19 insertions, 29 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index cfc3cff6e8d5..b2316c03f330 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1966,27 +1966,21 @@ static int proc_disconnectsignal_compat(struct usb_dev_state *ps, void __user *a
1966static int get_urb32(struct usbdevfs_urb *kurb, 1966static int get_urb32(struct usbdevfs_urb *kurb,
1967 struct usbdevfs_urb32 __user *uurb) 1967 struct usbdevfs_urb32 __user *uurb)
1968{ 1968{
1969 __u32 uptr; 1969 struct usbdevfs_urb32 urb32;
1970 if (!access_ok(VERIFY_READ, uurb, sizeof(*uurb)) || 1970 if (copy_from_user(&urb32, uurb, sizeof(*uurb)))
1971 __get_user(kurb->type, &uurb->type) ||
1972 __get_user(kurb->endpoint, &uurb->endpoint) ||
1973 __get_user(kurb->status, &uurb->status) ||
1974 __get_user(kurb->flags, &uurb->flags) ||
1975 __get_user(kurb->buffer_length, &uurb->buffer_length) ||
1976 __get_user(kurb->actual_length, &uurb->actual_length) ||
1977 __get_user(kurb->start_frame, &uurb->start_frame) ||
1978 __get_user(kurb->number_of_packets, &uurb->number_of_packets) ||
1979 __get_user(kurb->error_count, &uurb->error_count) ||
1980 __get_user(kurb->signr, &uurb->signr))
1981 return -EFAULT; 1971 return -EFAULT;
1982 1972 kurb->type = urb32.type;
1983 if (__get_user(uptr, &uurb->buffer)) 1973 kurb->endpoint = urb32.endpoint;
1984 return -EFAULT; 1974 kurb->status = urb32.status;
1985 kurb->buffer = compat_ptr(uptr); 1975 kurb->flags = urb32.flags;
1986 if (__get_user(uptr, &uurb->usercontext)) 1976 kurb->buffer = compat_ptr(urb32.buffer);
1987 return -EFAULT; 1977 kurb->buffer_length = urb32.buffer_length;
1988 kurb->usercontext = compat_ptr(uptr); 1978 kurb->actual_length = urb32.actual_length;
1989 1979 kurb->start_frame = urb32.start_frame;
1980 kurb->number_of_packets = urb32.number_of_packets;
1981 kurb->error_count = urb32.error_count;
1982 kurb->signr = urb32.signr;
1983 kurb->usercontext = compat_ptr(urb32.usercontext);
1990 return 0; 1984 return 0;
1991} 1985}
1992 1986
@@ -2198,18 +2192,14 @@ static int proc_ioctl_default(struct usb_dev_state *ps, void __user *arg)
2198#ifdef CONFIG_COMPAT 2192#ifdef CONFIG_COMPAT
2199static int proc_ioctl_compat(struct usb_dev_state *ps, compat_uptr_t arg) 2193static int proc_ioctl_compat(struct usb_dev_state *ps, compat_uptr_t arg)
2200{ 2194{
2201 struct usbdevfs_ioctl32 __user *uioc; 2195 struct usbdevfs_ioctl32 ioc32;
2202 struct usbdevfs_ioctl ctrl; 2196 struct usbdevfs_ioctl ctrl;
2203 u32 udata;
2204 2197
2205 uioc = compat_ptr((long)arg); 2198 if (copy_from_user(&ioc32, compat_ptr(arg), sizeof(ioc32)))
2206 if (!access_ok(VERIFY_READ, uioc, sizeof(*uioc)) ||
2207 __get_user(ctrl.ifno, &uioc->ifno) ||
2208 __get_user(ctrl.ioctl_code, &uioc->ioctl_code) ||
2209 __get_user(udata, &uioc->data))
2210 return -EFAULT; 2199 return -EFAULT;
2211 ctrl.data = compat_ptr(udata); 2200 ctrl.ifno = ioc32.ifno;
2212 2201 ctrl.ioctl_code = ioc32.ioctl_code;
2202 ctrl.data = compat_ptr(ioc32.data);
2213 return proc_ioctl(ps, &ctrl); 2203 return proc_ioctl(ps, &ctrl);
2214} 2204}
2215#endif 2205#endif