From: Greg KH Date: Tue, 16 Feb 2010 01:37:46 +0000 (-0800) Subject: USB: usbfs: only copy the actual data received X-Git-Tag: v2.6.31.13~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acbf8a14113c8abeb10a21cefc551d03bdd8f3f7;p=thirdparty%2Fkernel%2Fstable.git USB: usbfs: only copy the actual data received commit d4a4683ca054ed9917dfc9e3ff0f7ecf74ad90d6 upstream We need to only copy the data received by the device to userspace, not the whole kernel buffer, which can contain "stale" data. Thanks to Marcus Meissner for pointing this out and testing the fix. Reported-by: Marcus Meissner Tested-by: Marcus Meissner Cc: Alan Stern Cc: Linus Torvalds Cc: stable Signed-off-by: Greg Kroah-Hartman Acked-by: Jeff Mahoney --- diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index b8c49482209d7..52aabc7d4ba00 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -1240,9 +1240,9 @@ static int processcompl(struct async *as, void __user * __user *arg) void __user *addr = as->userurb; unsigned int i; - if (as->userbuffer) + if (as->userbuffer && urb->actual_length) if (copy_to_user(as->userbuffer, urb->transfer_buffer, - urb->transfer_buffer_length)) + urb->actual_length)) goto err_out; if (put_user(as->status, &userurb->status)) goto err_out; @@ -1368,9 +1368,9 @@ static int processcompl_compat(struct async *as, void __user * __user *arg) void __user *addr = as->userurb; unsigned int i; - if (as->userbuffer) + if (as->userbuffer && urb->actual_length) if (copy_to_user(as->userbuffer, urb->transfer_buffer, - urb->transfer_buffer_length)) + urb->actual_length)) return -EFAULT; if (put_user(as->status, &userurb->status)) return -EFAULT;