Commit cc1a7c4b authored by Al Viro's avatar Al Viro

usbdevfs: get rid of field-by-field copyin

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 30138384
...@@ -1966,27 +1966,21 @@ static int proc_disconnectsignal_compat(struct usb_dev_state *ps, void __user *a ...@@ -1966,27 +1966,21 @@ static int proc_disconnectsignal_compat(struct usb_dev_state *ps, void __user *a
static int get_urb32(struct usbdevfs_urb *kurb, static int get_urb32(struct usbdevfs_urb *kurb,
struct usbdevfs_urb32 __user *uurb) struct usbdevfs_urb32 __user *uurb)
{ {
__u32 uptr; struct usbdevfs_urb32 urb32;
if (!access_ok(VERIFY_READ, uurb, sizeof(*uurb)) || if (copy_from_user(&urb32, uurb, sizeof(*uurb)))
__get_user(kurb->type, &uurb->type) ||
__get_user(kurb->endpoint, &uurb->endpoint) ||
__get_user(kurb->status, &uurb->status) ||
__get_user(kurb->flags, &uurb->flags) ||
__get_user(kurb->buffer_length, &uurb->buffer_length) ||
__get_user(kurb->actual_length, &uurb->actual_length) ||
__get_user(kurb->start_frame, &uurb->start_frame) ||
__get_user(kurb->number_of_packets, &uurb->number_of_packets) ||
__get_user(kurb->error_count, &uurb->error_count) ||
__get_user(kurb->signr, &uurb->signr))
return -EFAULT; return -EFAULT;
kurb->type = urb32.type;
if (__get_user(uptr, &uurb->buffer)) kurb->endpoint = urb32.endpoint;
return -EFAULT; kurb->status = urb32.status;
kurb->buffer = compat_ptr(uptr); kurb->flags = urb32.flags;
if (__get_user(uptr, &uurb->usercontext)) kurb->buffer = compat_ptr(urb32.buffer);
return -EFAULT; kurb->buffer_length = urb32.buffer_length;
kurb->usercontext = compat_ptr(uptr); kurb->actual_length = urb32.actual_length;
kurb->start_frame = urb32.start_frame;
kurb->number_of_packets = urb32.number_of_packets;
kurb->error_count = urb32.error_count;
kurb->signr = urb32.signr;
kurb->usercontext = compat_ptr(urb32.usercontext);
return 0; return 0;
} }
...@@ -2198,18 +2192,14 @@ static int proc_ioctl_default(struct usb_dev_state *ps, void __user *arg) ...@@ -2198,18 +2192,14 @@ static int proc_ioctl_default(struct usb_dev_state *ps, void __user *arg)
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
static int proc_ioctl_compat(struct usb_dev_state *ps, compat_uptr_t arg) static int proc_ioctl_compat(struct usb_dev_state *ps, compat_uptr_t arg)
{ {
struct usbdevfs_ioctl32 __user *uioc; struct usbdevfs_ioctl32 ioc32;
struct usbdevfs_ioctl ctrl; struct usbdevfs_ioctl ctrl;
u32 udata;
uioc = compat_ptr((long)arg); if (copy_from_user(&ioc32, compat_ptr(arg), sizeof(ioc32)))
if (!access_ok(VERIFY_READ, uioc, sizeof(*uioc)) ||
__get_user(ctrl.ifno, &uioc->ifno) ||
__get_user(ctrl.ioctl_code, &uioc->ioctl_code) ||
__get_user(udata, &uioc->data))
return -EFAULT; return -EFAULT;
ctrl.data = compat_ptr(udata); ctrl.ifno = ioc32.ifno;
ctrl.ioctl_code = ioc32.ioctl_code;
ctrl.data = compat_ptr(ioc32.data);
return proc_ioctl(ps, &ctrl); return proc_ioctl(ps, &ctrl);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment