]>
Commit | Line | Data |
---|---|---|
976bf4e2 GKH |
1 | From d4a4683ca054ed9917dfc9e3ff0f7ecf74ad90d6 Mon Sep 17 00:00:00 2001 |
2 | From: Greg KH <greg@kroah.com> | |
3 | Date: Mon, 15 Feb 2010 09:37:46 -0800 | |
4 | Subject: USB: usbfs: only copy the actual data received | |
5 | ||
6 | From: Greg KH <greg@kroah.com> | |
7 | ||
8 | commit d4a4683ca054ed9917dfc9e3ff0f7ecf74ad90d6 upstream. | |
9 | ||
10 | We need to only copy the data received by the device to userspace, not | |
11 | the whole kernel buffer, which can contain "stale" data. | |
12 | ||
13 | Thanks to Marcus Meissner for pointing this out and testing the fix. | |
14 | ||
15 | Reported-by: Marcus Meissner <meissner@suse.de> | |
16 | Tested-by: Marcus Meissner <meissner@suse.de> | |
17 | Cc: Alan Stern <stern@rowland.harvard.edu> | |
18 | Cc: Linus Torvalds <torvalds@linux-foundation.org> | |
19 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
20 | ||
21 | --- | |
22 | drivers/usb/core/devio.c | 8 ++++---- | |
23 | 1 file changed, 4 insertions(+), 4 deletions(-) | |
24 | ||
25 | --- a/drivers/usb/core/devio.c | |
26 | +++ b/drivers/usb/core/devio.c | |
27 | @@ -1312,9 +1312,9 @@ static int processcompl(struct async *as | |
28 | void __user *addr = as->userurb; | |
29 | unsigned int i; | |
30 | ||
31 | - if (as->userbuffer) | |
32 | + if (as->userbuffer && urb->actual_length) | |
33 | if (copy_to_user(as->userbuffer, urb->transfer_buffer, | |
34 | - urb->transfer_buffer_length)) | |
35 | + urb->actual_length)) | |
36 | goto err_out; | |
37 | if (put_user(as->status, &userurb->status)) | |
38 | goto err_out; | |
39 | @@ -1435,9 +1435,9 @@ static int processcompl_compat(struct as | |
40 | void __user *addr = as->userurb; | |
41 | unsigned int i; | |
42 | ||
43 | - if (as->userbuffer) | |
44 | + if (as->userbuffer && urb->actual_length) | |
45 | if (copy_to_user(as->userbuffer, urb->transfer_buffer, | |
46 | - urb->transfer_buffer_length)) | |
47 | + urb->actual_length)) | |
48 | return -EFAULT; | |
49 | if (put_user(as->status, &userurb->status)) | |
50 | return -EFAULT; |