]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/2.6.27.46/usb-usbfs-only-copy-the-actual-data-received.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.27.46 / usb-usbfs-only-copy-the-actual-data-received.patch
CommitLineData
52aa51ba
GKH
1From d4a4683ca054ed9917dfc9e3ff0f7ecf74ad90d6 Mon Sep 17 00:00:00 2001
2From: Greg KH <greg@kroah.com>
3Date: Mon, 15 Feb 2010 09:37:46 -0800
4Subject: USB: usbfs: only copy the actual data received
5
6From: Greg KH <greg@kroah.com>
7
8commit d4a4683ca054ed9917dfc9e3ff0f7ecf74ad90d6 upstream.
9
10We need to only copy the data received by the device to userspace, not
11the whole kernel buffer, which can contain "stale" data.
12
13Thanks to Marcus Meissner for pointing this out and testing the fix.
14
15Reported-by: Marcus Meissner <meissner@suse.de>
16Tested-by: Marcus Meissner <meissner@suse.de>
17Cc: Alan Stern <stern@rowland.harvard.edu>
18Cc: Linus Torvalds <torvalds@linux-foundation.org>
19Signed-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@@ -1224,9 +1224,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@@ -1347,9 +1347,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;