public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Németh Márton" <nm127@freemail.hu>
To: Kees Cook <kees.cook@canonical.com>
Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman <gregkh@suse.de>,
	Oliver Neukum <oliver@neukum.org>, Joe Perches <joe@perches.com>,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: don't trust report_size for buffer size
Date: Mon, 11 Oct 2010 21:34:59 +0200	[thread overview]
Message-ID: <4CB366E3.9070903@freemail.hu> (raw)
In-Reply-To: <20101011191119.GN4991@outflux.net>

Kees Cook wrote:
> Hi Németh,
> 
> On Mon, Oct 11, 2010 at 08:54:04PM +0200, Németh Márton wrote:
>> There might be similar problem also in the case USB_DEVICE_ID_CODEMERCS_IOW56. There
>> is buf is allocated with usb_alloc_coherent() to the size dev->report_size. However,
>> some lines later the copy_from_user() function tries to copy "count" number of
>> bytes to the dev->report_size allocated buffer. Unfortunately I don't have such
>> devices to try the driver so these are just coming from "static analysis".
> 
> I don't think the USB_DEVICE_ID_CODEMERCS_IOW56 path is a problem:
> 
>         if (count != dev->report_size) {
>                 retval = -EINVAL;
>                 goto exit;
>         }

You are right, I missed this condition.

>         switch (dev->product_id) {
> ...
>         case USB_DEVICE_ID_CODEMERCS_IOW56:
> ...
>                 buf = usb_alloc_coherent(dev->udev, dev->report_size,
>                                          GFP_KERNEL, &int_out_urb->transfer_dma);
> ...
>                 if (copy_from_user(buf, user_buffer, count)) {
> 
> i.e. count must == dev->report_size, and the buf is allocated with size
> dev->report_size even though copy_from_user uses "count".
> 
> -Kees
> 


      reply	other threads:[~2010-10-11 19:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-11 18:28 [PATCH] usb: don't trust report_size for buffer size Kees Cook
2010-10-11 18:54 ` Németh Márton
2010-10-11 19:11   ` Kees Cook
2010-10-11 19:34     ` Németh Márton [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=4CB366E3.9070903@freemail.hu \
    --to=nm127@freemail.hu \
    --cc=gregkh@suse.de \
    --cc=joe@perches.com \
    --cc=kees.cook@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=oliver@neukum.org \
    /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