From: Valdis.Kletnieks@vt.edu
To: Armando Visconti <armando.visconti@st.com>
Cc: jkosina@suse.cz, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] HID: Fixed a crash in hid_report_raw_event() function.
Date: Fri, 20 May 2011 12:02:04 -0400 [thread overview]
Message-ID: <11173.1305907324@localhost> (raw)
In-Reply-To: Your message of "Thu, 19 May 2011 21:41:22 +0200." <1305834082-14888-1-git-send-email-armando.visconti@st.com>
[-- Attachment #1: Type: text/plain, Size: 1528 bytes --]
On Thu, 19 May 2011 21:41:22 +0200, Armando Visconti said:
> I'm using a Data Modul EasyTouch USB multitouch controller,
> which is issuing a hid report with a size equals to 0. The rsize
> value gets set to 536870912 and Linux is crashing in the memset
> because the value is too big.
>
> Signed-off-by: Armando Visconti <armando.visconti@st.com>
> ---
> drivers/hid/hid-core.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index c3d6626..3e972e3 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -1045,6 +1045,9 @@ void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
>
> rsize = ((report->size - 1) >> 3) + 1;
>
> + if (rsize > HID_MAX_BUFFER_SIZE)
> + rsize = HID_MAX_BUFFER_SIZE;
> +
> if (csize < rsize) {
> dbg_hid("report %d is too short, (%d < %d)\n", report->id,
> csize, rsize);
I'm thinking this is papering over the bug, and causing us to process a max-sized
buffer when the other end gave *zero* bytes back - this can't be good.
Probably should be more like this:
if (!report->size) then /*
rsize = MIN_VALID_SIZE; /* whatever it should be here */
else {
rsize = ((report->size - 1) >> 3) + 1;
if (rsize > HID_MAX_BUFFER_SIZE)
rsize = HID_MAX_BUFFER_SIZE;
}
if (csize < rsize) {
That last if() still looks squirrely - if we have an effectively zero rsize,
the report is short and the dbg_hid should fire. Did we want "csize > rsize"
instead?
[-- Attachment #2: Type: application/pgp-signature, Size: 227 bytes --]
prev parent reply other threads:[~2011-05-20 16:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-19 19:41 [PATCH] HID: Fixed a crash in hid_report_raw_event() function Armando Visconti
2011-05-20 8:26 ` Jiri Kosina
2011-05-20 16:02 ` Valdis.Kletnieks [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=11173.1305907324@localhost \
--to=valdis.kletnieks@vt.edu \
--cc=armando.visconti@st.com \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@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).