From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] HID: hid-logitech-dj: add some range checks
Date: Tue, 05 Mar 2013 13:06:26 +0000 [thread overview]
Message-ID: <20130305130626.GA17801@longonot.mountain> (raw)
We can't trust dj_report->device_index because it comes from the
user and hasn't been range checked. It is used as an offset into
the djrcv_dev->paired_dj_devices[] array which has 7 elements.
There is one range check already in logi_dj_recv_add_djhid_device()
and I have copy and pasted that here.
DJ_DEVICE_INDEX_MIN is 1.
DJ_DEVICE_INDEX_MAX is 6.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This is a static checker fix and I'm not certain it's correct,
please look it over carefully.
I do not know this code well, so I don't know why a zero index is
invalid.
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index 9500f2f..c01cd25 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -701,6 +701,13 @@ static int logi_dj_raw_event(struct hid_device *hdev,
* anything else with it.
*/
+ if ((dj_report->device_index < DJ_DEVICE_INDEX_MIN) ||
+ (dj_report->device_index > DJ_DEVICE_INDEX_MAX)) {
+ dev_err(&hdev->dev, "%s: invalid device index:%d\n", __func__,
+ dj_report->device_index);
+ return true;
+ }
+
spin_lock_irqsave(&djrcv_dev->lock, flags);
if (dj_report->report_id = REPORT_ID_DJ_SHORT) {
switch (dj_report->report_type) {
next reply other threads:[~2013-03-05 13:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-05 13:06 Dan Carpenter [this message]
2013-03-05 14:47 ` [patch] HID: hid-logitech-dj: add some range checks Benjamin Tissoires
2013-03-05 16:34 ` Nestor Lopez Casado
2013-03-05 17:45 ` Dan Carpenter
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=20130305130626.GA17801@longonot.mountain \
--to=dan.carpenter@oracle.com \
--cc=jkosina@suse.cz \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-input@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