Skip to content

Commit daf6cd0

Browse files
Eliasvandtor
authored andcommitted
Input: uinput - sanity check on ff_effects_max and EV_FF
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> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent fbae10d commit daf6cd0

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎drivers/input/misc/uinput.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ static int uinput_create_device(struct uinput_device *udev)
272272
input_set_events_per_packet(dev, 60);
273273
}
274274

275+
if (test_bit(EV_FF, dev->evbit) && !udev->ff_effects_max) {
276+
printk(KERN_DEBUG "%s: ff_effects_max should be non-zero when FF_BIT is set\n",
277+
UINPUT_NAME);
278+
error = -EINVAL;
279+
goto fail1;
280+
}
281+
275282
if (udev->ff_effects_max) {
276283
error = input_ff_create(dev, udev->ff_effects_max);
277284
if (error)

0 commit comments

Comments
 (0)