USB: usbfs: only copy the actual data received

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Tuesday, February 16, 2010 - 6:59 pm

Gitweb:     http://git.kernel.org/linus/d4a4683ca054ed9917dfc9e3ff0f7ecf74ad90d6
Commit:     d4a4683ca054ed9917dfc9e3ff0f7ecf74ad90d6
Parent:     0813e22d4e0d618eac9b47bec942bf856adca4c5
Author:     Greg KH <greg@kroah.com>
AuthorDate: Mon Feb 15 09:37:46 2010 -0800
Committer:  Greg Kroah-Hartman <gregkh@suse.de>
CommitDate: Tue Feb 16 15:11:01 2010 -0800

    USB: usbfs: only copy the actual data received
    
    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 <meissner@suse.de>
    Tested-by: Marcus Meissner <meissner@suse.de>
    Cc: Alan Stern <stern@rowland.harvard.edu>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: stable <stable@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/usb/core/devio.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 6e8bcdf..ca948bb 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1312,9 +1312,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;
@@ -1475,9 +1475,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;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
USB: usbfs: only copy the actual data received, Linux Kernel Mailing ..., (Tue Feb 16, 6:59 pm)