From: Elias Vanderstuyft <elias.vds@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-api@vger.kernel.org,
linux-kernel@vger.kernel.org,
Elias Vanderstuyft <elias.vds@gmail.com>
Subject: [PATCH 2/2] Input: uinput: Sanity check on ff_effects_max and EV_FF
Date: Thu, 17 Sep 2015 19:29:48 +0200 [thread overview]
Message-ID: <1442510988-3164-3-git-send-email-elias.vds@gmail.com> (raw)
In-Reply-To: <1442510988-3164-1-git-send-email-elias.vds@gmail.com>
Currently the user can specify a non-zero value for ff_effects_max,
without setting the EV_FF bit.
Inversely,
the user can also set ff_effects_max to zero with the EV_FF bit set,
in this case the uninitialized method ff->upload can be dereferenced,
resulting in a kernel oops.
Instead of adding a check in uinput_create_device() and
omitting setup of ff-core infrastructure silently in case the check fails,
perform the check early in uinput_setup_device(),
and print a helpful message and return -EINVAL in case the check fails.
Signed-off-by: Elias Vanderstuyft <elias.vds@gmail.com>
---
drivers/input/misc/uinput.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 345df9b..3a90a16 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -393,6 +393,21 @@ static int uinput_setup_device(struct uinput_device *udev,
if (IS_ERR(user_dev))
return PTR_ERR(user_dev);
+ if (!!user_dev->ff_effects_max ^ test_bit(EV_FF, dev->evbit)) {
+ if (user_dev->ff_effects_max)
+ printk(KERN_DEBUG
+ "%s: ff_effects_max (%u) should be zero "
+ "when FF_BIT is not set\n",
+ UINPUT_NAME, user_dev->ff_effects_max);
+ else
+ printk(KERN_DEBUG
+ "%s: ff_effects_max should be non-zero "
+ "when FF_BIT is set\n",
+ UINPUT_NAME);
+ retval = -EINVAL;
+ goto exit;
+ }
+
udev->ff_effects_max = user_dev->ff_effects_max;
/* Ensure name is filled in */
--
1.9.3
next prev parent reply other threads:[~2015-09-17 17:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-17 17:29 [PATCH 0/2] Input: Improve handling of ff max_effects Elias Vanderstuyft
2015-09-17 17:29 ` [PATCH 1/2] Input: Document and check on implicitly defined FF_MAX_EFFECTS Elias Vanderstuyft
2015-10-15 0:52 ` Dmitry Torokhov
2015-09-17 17:29 ` Elias Vanderstuyft [this message]
2015-10-15 0:52 ` [PATCH 2/2] Input: uinput: Sanity check on ff_effects_max and EV_FF Dmitry Torokhov
2015-11-05 22:34 ` Elias Vanderstuyft
2015-11-06 1:32 ` Dmitry Torokhov
2015-11-08 17:37 ` [PATCH v2 " Elias Vanderstuyft
2015-12-19 1:50 ` Dmitry Torokhov
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=1442510988-3164-3-git-send-email-elias.vds@gmail.com \
--to=elias.vds@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-api@vger.kernel.org \
--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
all inboxes | Powered by JetHome®