From: David Herrmann <dh.herrmann@googlemail.com>
To: linux-input@vger.kernel.org
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
David Herrmann <dh.herrmann@googlemail.com>,
stable@kernel.org
Subject: [PATCH] input: fix input_open_file() accessing out-of-bound buffers
Date: Thu, 13 Sep 2012 18:17:30 +0200 [thread overview]
Message-ID: <1347553050-25480-1-git-send-email-dh.herrmann@googlemail.com> (raw)
The "input_table" array is very small and we cannot be sure that the file
the user opens has a minor-ID below 256 (8 << 5). Hence, simply check that
the minor isn't out-of-bounds. If it is, return -ENODEV.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Cc: <stable@kernel.org>
---
drivers/input/input.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 8921c61..eb65ad7 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -2095,13 +2095,19 @@ static int input_open_file(struct inode *inode, struct file *file)
struct input_handler *handler;
const struct file_operations *old_fops, *new_fops = NULL;
int err;
+ unsigned int minor_group;
err = mutex_lock_interruptible(&input_mutex);
if (err)
return err;
/* No load-on-demand here? */
- handler = input_table[iminor(inode) >> 5];
+
+ minor_group = iminor(inode) >> 5;
+ if (minor_group >= sizeof(input_table) / sizeof(*input_table))
+ return -ENODEV;
+
+ handler = input_table[minor_group];
if (handler)
new_fops = fops_get(handler->fops);
--
1.7.12
next reply other threads:[~2012-09-13 16:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-13 16:17 David Herrmann [this message]
2012-09-13 16:18 ` [PATCH] input: fix input_open_file() accessing out-of-bound buffers David Herrmann
2012-09-13 16:57 ` Dmitry Torokhov
2012-09-13 17:00 ` David Herrmann
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=1347553050-25480-1-git-send-email-dh.herrmann@googlemail.com \
--to=dh.herrmann@googlemail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=stable@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).