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,
David Herrmann <dh.herrmann@gmail.com>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
Elias Vanderstuyft <elias.vds@gmail.com>
Subject: [PATCH v2 2/2] Input: uinput: Sanity check on ff_effects_max and EV_FF
Date: Sun, 8 Nov 2015 18:37:34 +0100 [thread overview]
Message-ID: <1447004254-12431-1-git-send-email-elias.vds@gmail.com> (raw)
In-Reply-To: <1442510988-3164-3-git-send-email-elias.vds@gmail.com>
Currently the user can set ff_effects_max to zero with the EV_FF bit
(and the FF_GAIN and/or FF_AUTOCENTER bits) set,
in this case the uninitialized methods
ff->set_gain and/or ff->set_autocenter can be dereferenced,
resulting in a kernel oops.
Check in uinput_create_device() and
print a helpful message and return -EINVAL in case the check fails.
Signed-off-by: Elias Vanderstuyft <elias.vds@gmail.com>
---
Changes in v2:
- Rebase on pending patches from David Herrmann and Benjamin Tissoires:
- v3 Input: uinput - add new UINPUT_DEV_SETUP and UI_ABS_SETUP ioctl
- Input: uinput - rework ABS validation
- Don't require EV_FF bit to be set when ff_effects_max is non-zero
- Move check from uinput_setup_device() to uinput_create_device()
- Update commit description
At the same time, the new UINPUT_DEV_SETUP and UI_ABS_SETUP ioctls were
tested as well (in both orders).
The legacy write() (instead of UINPUT_DEV_SETUP) was also tested.
drivers/input/misc/uinput.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 1d93037..b9d0713 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -272,6 +272,13 @@ static int uinput_create_device(struct uinput_device *udev)
input_set_events_per_packet(dev, 60);
}
+ if (test_bit(EV_FF, dev->evbit) && !udev->ff_effects_max) {
+ printk(KERN_DEBUG "%s: ff_effects_max should be non-zero when FF_BIT is set\n",
+ UINPUT_NAME);
+ error = -EINVAL;
+ goto fail1;
+ }
+
if (udev->ff_effects_max) {
error = input_ff_create(dev, udev->ff_effects_max);
if (error)
--
1.9.3
next prev parent reply other threads:[~2015-11-08 17:38 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
[not found] ` <1442510988-3164-1-git-send-email-elias.vds-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-17 17:29 ` [PATCH 2/2] Input: uinput: Sanity check on ff_effects_max and EV_FF Elias Vanderstuyft
2015-10-15 0:52 ` Dmitry Torokhov
2015-11-05 22:34 ` Elias Vanderstuyft
[not found] ` <CADbOyBSeXDLzaSj=z3W2oMzg1DV3fP651wzLztUezSmf3B05qA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-11-06 1:32 ` Dmitry Torokhov
2015-11-08 17:37 ` Elias Vanderstuyft [this message]
2015-12-19 1:50 ` [PATCH v2 " 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=1447004254-12431-1-git-send-email-elias.vds@gmail.com \
--to=elias.vds@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--cc=dh.herrmann@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;
as well as URLs for NNTP newsgroup(s).