linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Gwendal Grignou <gwendal@chromium.org>
Cc: jkosina@suse.cz, stable@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH] HID: i2c-hid: prevent buffer overflow in early IRQ
Date: Thu, 11 Dec 2014 20:17:39 -0500	[thread overview]
Message-ID: <20141212011739.GA14905@mail.corp.redhat.com> (raw)
In-Reply-To: <1418342565-22161-1-git-send-email-gwendal@chromium.org>

On Dec 11 2014 or thereabouts, Gwendal Grignou wrote:
> Before ->start() is called, bufsize size is set to HID_MIN_BUFFER_SIZE,
> 64 bytes. While processing the IRQ, we were asking to receive up to
> wMaxInputLength bytes, which can be bigger than 64 bytes.
> 
> Later, when ->start is run, a proper bufsize will be calculated.
> 
> Given wMaxInputLength is said to be unreliable in other part of the
> code, set to receive only what we can even if it results in truncated
> reports.
> 
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> Cc: stable@vger.kernel.org
> ---

Yep, well spotted. Makes sense to me.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Cheers,
Benjamin

>  drivers/hid/i2c-hid/i2c-hid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
> index 226375e..d32037c 100644
> --- a/drivers/hid/i2c-hid/i2c-hid.c
> +++ b/drivers/hid/i2c-hid/i2c-hid.c
> @@ -370,7 +370,7 @@ static int i2c_hid_hwreset(struct i2c_client *client)
>  static void i2c_hid_get_input(struct i2c_hid *ihid)
>  {
>  	int ret, ret_size;
> -	int size = le16_to_cpu(ihid->hdesc.wMaxInputLength);
> +	int size = ihid->bufsize;
>  
>  	ret = i2c_master_recv(ihid->client, ihid->inbuf, size);
>  	if (ret != size) {
> -- 
> 2.2.0.rc0.207.ga3a616c
> 

           reply	other threads:[~2014-12-12  1:17 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1418342565-22161-1-git-send-email-gwendal@chromium.org>]

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=20141212011739.GA14905@mail.corp.redhat.com \
    --to=benjamin.tissoires@redhat.com \
    --cc=gwendal@chromium.org \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=stable@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).