From: Linus Torvalds <torvalds@linux-foundation.org>
To: Markus Rechberger <mrechberger@gmail.com>
Cc: werner@guyane.dyn-o-saur.com, Greg KH <greg@kroah.com>,
Marcus Meissner <meissner@suse.de>,
linux-kernel@vger.kernel.org
Subject: Re: 2.6.33 bugs (USBFS, Intel graphic)
Date: Fri, 26 Feb 2010 20:11:00 -0800 (PST) [thread overview]
Message-ID: <alpine.LFD.2.00.1002261953450.4513@localhost.localdomain> (raw)
In-Reply-To: <d9def9db1002261942k27b64dd4g670dd29969c93cbf@mail.gmail.com>
On Sat, 27 Feb 2010, Markus Rechberger wrote:
>
> commit d4a4683ca054ed9917dfc9e3ff0f7ecf74ad90d6 upstream.
>
> this patch breaks isochronous USBFS support, please revert that patch!
>
> http://sundtek.de/images/tvtime-bildfehler.jpg
>
> with the patch reverted:
> http://sundtek.de/images/tvtime-working.png
Hmm. That would seem to mean that either the app (tvtime) depended in some
_really_ interesting way on some random data that was never even
transferred from the device, or 'urb->actual_length' isn't actually
reliable in some cases.
Does this patch (_instead_ of reverting things) change any behavior? Do
you get that warning? It will zero-fill the remainder of the buffer.
(UNTESTED! It compiled for me, and looks ok, but whatever..)
Linus
---
drivers/usb/core/devio.c | 53 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index a678186..8afee02 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1305,6 +1305,47 @@ static int proc_unlinkurb(struct dev_state *ps, void __user *arg)
return 0;
}
+/*
+ * Fixme! We don't have a good memclear_user(), so we do it with a
+ * stupid copy_to_user() loop from a zero buffer.
+ */
+static int memclear_user(void __user *dst, long len)
+{
+ while (len > 0) {
+ static const char zeroes[128];
+ unsigned long n = len;
+
+ if (n > sizeof(zeroes))
+ n = sizeof(zeroes);
+ if (copy_to_user(dst, zeroes, n))
+ return -EFAULT;
+ dst += n;
+ len -= n;
+ }
+ return 0;
+}
+
+static int copy_buffer_to_user(struct async *as, struct urb *urb)
+{
+ void __user *dst = as->userbuffer;
+ void *src;
+ unsigned long len, full;
+
+ if (!dst)
+ return 0;
+
+ len = urb->actual_length;
+ full = urb->transfer_buffer_length;
+ if (WARN_ONCE(len > full, "actual_length (%lu) > transfer_buffer_length (%lu)", len, full))
+ len = full;
+
+ src = urb->transfer_buffer;
+ if (copy_to_user(dst, src, len))
+ return -EFAULT;
+
+ return memclear_user(dst + len, full - len);
+}
+
static int processcompl(struct async *as, void __user * __user *arg)
{
struct urb *urb = as->urb;
@@ -1312,10 +1353,8 @@ static int processcompl(struct async *as, void __user * __user *arg)
void __user *addr = as->userurb;
unsigned int i;
- if (as->userbuffer && urb->actual_length)
- if (copy_to_user(as->userbuffer, urb->transfer_buffer,
- urb->actual_length))
- goto err_out;
+ if (copy_buffer_to_user(as, urb))
+ goto err_out;
if (put_user(as->status, &userurb->status))
goto err_out;
if (put_user(urb->actual_length, &userurb->actual_length))
@@ -1480,10 +1519,8 @@ static int processcompl_compat(struct async *as, void __user * __user *arg)
void __user *addr = as->userurb;
unsigned int i;
- if (as->userbuffer && urb->actual_length)
- if (copy_to_user(as->userbuffer, urb->transfer_buffer,
- urb->actual_length))
- return -EFAULT;
+ if (copy_buffer_to_user(as, urb))
+ return -EFAULT;
if (put_user(as->status, &userurb->status))
return -EFAULT;
if (put_user(urb->actual_length, &userurb->actual_length))
prev parent reply other threads:[~2010-02-27 4:11 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-27 3:42 Markus Rechberger
2010-02-27 3:56 ` Greg KH
2010-02-27 4:05 ` Markus Rechberger
2010-02-27 4:18 ` Greg KH
2010-02-27 4:29 ` Linus Torvalds
2010-02-27 4:34 ` Markus Rechberger
2010-02-27 5:17 ` Greg KH
2010-02-27 5:26 ` Greg KH
2010-02-27 5:38 ` Markus Rechberger
2010-02-27 5:48 ` Greg KH
2010-02-27 11:00 ` Markus Rechberger
2010-02-27 12:15 ` Pekka Enberg
2010-02-27 12:17 ` Pekka Enberg
2010-02-27 16:49 ` Jesse Barnes
2010-02-27 18:08 ` Markus Rechberger
2010-02-27 22:33 ` Markus Rechberger
2010-02-27 17:20 ` Alan Stern
2010-03-03 0:09 ` Greg KH
2010-03-05 21:37 ` Markus Rechberger
2010-03-06 16:30 ` Markus Rechberger
2010-03-06 17:06 ` Greg KH
2010-03-06 20:04 ` Alan Stern
2010-02-27 4:11 ` Linus Torvalds [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.2.00.1002261953450.4513@localhost.localdomain \
--to=torvalds@linux-foundation.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=meissner@suse.de \
--cc=mrechberger@gmail.com \
--cc=werner@guyane.dyn-o-saur.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®