<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/input/misc/uinput.c, branch v4.15</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v4.15</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.15'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2017-11-10T18:29:53Z</updated>
<entry>
<title>Input: uinput - unlock on allocation failure in ioctl</title>
<updated>2017-11-10T18:29:53Z</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2017-11-10T18:21:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=781f2dd0a5eb8e660c0a5dbb11a69aed72f26657'/>
<id>urn:sha1:781f2dd0a5eb8e660c0a5dbb11a69aed72f26657</id>
<content type='text'>
We have to unlock before returning if input_allocate_device() fails.

Fixes: 04ce40a61a91 ("Input: uinput - remove uinput_allocate_device()")
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;</content>
</entry>
<entry>
<title>Input: uinput - fold header into the driver proper</title>
<updated>2017-10-23T23:32:31Z</updated>
<author>
<name>Dmitry Torokhov</name>
<email>dmitry.torokhov@gmail.com</email>
</author>
<published>2017-09-04T19:19:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a11bc476b987925654369411dd8281a60cb5a175'/>
<id>urn:sha1:a11bc476b987925654369411dd8281a60cb5a175</id>
<content type='text'>
There is nothing in the uinput kernel header that is of use to anyone in
the kernel besides the uinput driver itself, so let's fold it into the
driver code (leaving uapi part intact).

Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;</content>
</entry>
<entry>
<title>Input: uinput - remove uinput_allocate_device()</title>
<updated>2017-10-23T23:32:30Z</updated>
<author>
<name>Dmitry Torokhov</name>
<email>dmitry.torokhov@gmail.com</email>
</author>
<published>2017-09-06T23:42:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=04ce40a61a9164f82065eade491099b185c17a65'/>
<id>urn:sha1:04ce40a61a9164f82065eade491099b185c17a65</id>
<content type='text'>
There is no need for this wrapper; let's use input_allocate_device()
directly, and complete initialization in uinput_create_device().

Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;</content>
</entry>
<entry>
<title>Input: uinput - fix coding style in uinput_ioctl_handler()</title>
<updated>2017-10-23T23:32:30Z</updated>
<author>
<name>Dmitry Torokhov</name>
<email>dmitry.torokhov@gmail.com</email>
</author>
<published>2017-09-06T23:34:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c06616528f283c05ebcd24a12cf80007efbe8f21'/>
<id>urn:sha1:c06616528f283c05ebcd24a12cf80007efbe8f21</id>
<content type='text'>
"case"s in switch statement were indented extra level, let's fix that.

Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;</content>
</entry>
<entry>
<title>Input: uinput - allow FF requests to time out</title>
<updated>2017-10-23T23:32:29Z</updated>
<author>
<name>Dmitry Torokhov</name>
<email>dmitry.torokhov@gmail.com</email>
</author>
<published>2017-09-06T23:31:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8e009118a45af30451ff4bbae2b6efd9575d6694'/>
<id>urn:sha1:8e009118a45af30451ff4bbae2b6efd9575d6694</id>
<content type='text'>
Previously uinput force feedback requests waited for the userspace
indefinitely, which caused users to block when uinput server process
become unresponsive. Let's establish a 30 seconds deadline for servicing
upload and erase force feedback effect actions, so that users have a
chance to abort stuck requests.

Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;</content>
</entry>
<entry>
<title>Input: uinput - avoid crash when sending FF request to device going away</title>
<updated>2017-09-21T23:31:23Z</updated>
<author>
<name>Dmitry Torokhov</name>
<email>dmitry.torokhov@gmail.com</email>
</author>
<published>2017-09-06T23:22:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6b4877c7bdc6ae39ce03716df7caeecf204697eb'/>
<id>urn:sha1:6b4877c7bdc6ae39ce03716df7caeecf204697eb</id>
<content type='text'>
If FF request comes in while uinput device is going away,
uinput_request_send() will fail with -ENODEV, and uinput_request_submit()
will attempt to mark the slot as unused by calling uinput_request_done().
Unfortunately in this case we haven't initialized request-&gt;done completion
yet, and we get a crash:

[   39.402036] BUG: spinlock bad magic on CPU#1, fftest/3108
[   39.402046]  lock: 0xffff88006a93bb00, .magic: 00000000, .owner: /39, .owner_cpu: 1217155072
[   39.402055] CPU: 1 PID: 3108 Comm: fftest Tainted: G        W 4.13.0+ #15
[   39.402059] Hardware name: LENOVO 20HQS0EG02/20HQS0EG02, BIOS N1MET37W (1.22 ) 07/04/2017
[   39.402064]  0000000000000086 f0fad82f3ceaa120 ffff88006a93b9a0 ffffffff9de941bb
[   39.402077]  ffff88026df8ae00 ffff88006a93bb00 ffff88006a93b9c0 ffffffff9dca62b7
[   39.402088]  ffff88006a93bb00 ffff88006a93baf8 ffff88006a93b9e0 ffffffff9dca62e7
[   39.402099] Call Trace:
[   39.402112]  [&lt;ffffffff9de941bb&gt;] dump_stack+0x4d/0x63
[   39.402123]  [&lt;ffffffff9dca62b7&gt;] spin_dump+0x97/0x9c
[   39.402130]  [&lt;ffffffff9dca62e7&gt;] spin_bug+0x2b/0x2d
[   39.402138]  [&lt;ffffffff9dca6373&gt;] do_raw_spin_lock+0x28/0xfd
[   39.402147]  [&lt;ffffffff9e3055cd&gt;] _raw_spin_lock_irqsave+0x19/0x1f
[   39.402154]  [&lt;ffffffff9dca05b7&gt;] complete+0x1d/0x48
[   39.402162]  [&lt;ffffffffc04f30af&gt;] 0xffffffffc04f30af
[   39.402167]  [&lt;ffffffffc04f468c&gt;] 0xffffffffc04f468c
[   39.402177]  [&lt;ffffffff9dd59c16&gt;] ? __slab_free+0x22f/0x359
[   39.402184]  [&lt;ffffffff9dcc13e9&gt;] ? tk_clock_read+0xc/0xe
[   39.402189]  [&lt;ffffffffc04f471f&gt;] 0xffffffffc04f471f
[   39.402195]  [&lt;ffffffff9dc9ffe5&gt;] ? __wake_up+0x44/0x4b
[   39.402200]  [&lt;ffffffffc04f3240&gt;] ? 0xffffffffc04f3240
[   39.402207]  [&lt;ffffffff9e0f57f3&gt;] erase_effect+0xa1/0xd2
[   39.402214]  [&lt;ffffffff9e0f58c6&gt;] input_ff_flush+0x43/0x5c
[   39.402219]  [&lt;ffffffffc04f32ad&gt;] 0xffffffffc04f32ad
[   39.402227]  [&lt;ffffffff9e0f174f&gt;] input_flush_device+0x3d/0x51
[   39.402234]  [&lt;ffffffff9e0f69ae&gt;] evdev_flush+0x49/0x5c
[   39.402243]  [&lt;ffffffff9dd62d6e&gt;] filp_close+0x3f/0x65
[   39.402253]  [&lt;ffffffff9dd7dcf7&gt;] put_files_struct+0x66/0xc1
[   39.402261]  [&lt;ffffffff9dd7ddeb&gt;] exit_files+0x47/0x4e
[   39.402270]  [&lt;ffffffff9dc6b329&gt;] do_exit+0x483/0x969
[   39.402278]  [&lt;ffffffff9dc73211&gt;] ? recalc_sigpending_tsk+0x3d/0x44
[   39.402285]  [&lt;ffffffff9dc6c7a2&gt;] do_group_exit+0x42/0xb0
[   39.402293]  [&lt;ffffffff9dc767e1&gt;] get_signal+0x58d/0x5bf
[   39.402300]  [&lt;ffffffff9dc03701&gt;] do_signal+0x37/0x53e
[   39.402307]  [&lt;ffffffff9e0f8401&gt;] ? evdev_ioctl_handler+0xac8/0xb04
[   39.402314]  [&lt;ffffffff9e0f8464&gt;] ? evdev_ioctl+0x10/0x12
[   39.402321]  [&lt;ffffffff9dd74cfa&gt;] ? do_vfs_ioctl+0x42e/0x501
[   39.402328]  [&lt;ffffffff9dc0170e&gt;] prepare_exit_to_usermode+0x66/0x90
[   39.402333]  [&lt;ffffffff9dc0181b&gt;] syscall_return_slowpath+0xe3/0xec
[   39.402339]  [&lt;ffffffff9e305b7b&gt;] int_ret_from_sys_call+0x25/0x8f

While we could solve this by simply initializing the completion earlier, we
are better off rearranging the code a bit so we avoid calling complete() on
requests that we did not send out. This patch consolidates marking request
slots as free in one place (in uinput_request_submit(), the same place
where we acquire them) and having everyone else simply signal completion
of the requests.

Fixes: 00ce756ce53a ("Input: uinput - mark failed submission requests as free")
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;</content>
</entry>
<entry>
<title>Input: uinput - avoid FF flush when destroying device</title>
<updated>2017-09-21T23:31:22Z</updated>
<author>
<name>Dmitry Torokhov</name>
<email>dmitry.torokhov@gmail.com</email>
</author>
<published>2017-09-02T00:13:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e8b95728f724797f958912fd9b765a695595d3a6'/>
<id>urn:sha1:e8b95728f724797f958912fd9b765a695595d3a6</id>
<content type='text'>
Normally, when input device supporting force feedback effects is being
destroyed, we try to "flush" currently playing effects, so that the
physical device does not continue vibrating (or executing other effects).
Unfortunately this does not work well for uinput as flushing of the effects
deadlocks with the destroy action:

- if device is being destroyed because the file descriptor is being closed,
  then there is noone to even service FF requests;

- if device is being destroyed because userspace sent UI_DEV_DESTROY,
  while theoretically it could be possible to service FF requests,
  userspace is unlikely to do so (they'd need to make sure FF handling
  happens on a separate thread) even if kernel solves the issue with FF
  ioctls deadlocking with UI_DEV_DESTROY ioctl on udev-&gt;mutex.

To avoid lockups like the one below, let's install a custom input device
flush handler, and avoid trying to flush force feedback effects when we
destroying the device, and instead rely on uinput to shut off the device
properly.

NMI watchdog: Watchdog detected hard LOCKUP on cpu 3
...
 &lt;&lt;EOE&gt;&gt;  [&lt;ffffffff817a0307&gt;] _raw_spin_lock_irqsave+0x37/0x40
 [&lt;ffffffff810e633d&gt;] complete+0x1d/0x50
 [&lt;ffffffffa00ba08c&gt;] uinput_request_done+0x3c/0x40 [uinput]
 [&lt;ffffffffa00ba587&gt;] uinput_request_submit.part.7+0x47/0xb0 [uinput]
 [&lt;ffffffffa00bb62b&gt;] uinput_dev_erase_effect+0x5b/0x76 [uinput]
 [&lt;ffffffff815d91ad&gt;] erase_effect+0xad/0xf0
 [&lt;ffffffff815d929d&gt;] flush_effects+0x4d/0x90
 [&lt;ffffffff815d4cc0&gt;] input_flush_device+0x40/0x60
 [&lt;ffffffff815daf1c&gt;] evdev_cleanup+0xac/0xc0
 [&lt;ffffffff815daf5b&gt;] evdev_disconnect+0x2b/0x60
 [&lt;ffffffff815d74ac&gt;] __input_unregister_device+0xac/0x150
 [&lt;ffffffff815d75f7&gt;] input_unregister_device+0x47/0x70
 [&lt;ffffffffa00bac45&gt;] uinput_destroy_device+0xb5/0xc0 [uinput]
 [&lt;ffffffffa00bb2de&gt;] uinput_ioctl_handler.isra.9+0x65e/0x740 [uinput]
 [&lt;ffffffff811231ab&gt;] ? do_futex+0x12b/0xad0
 [&lt;ffffffffa00bb3f8&gt;] uinput_ioctl+0x18/0x20 [uinput]
 [&lt;ffffffff81241248&gt;] do_vfs_ioctl+0x298/0x480
 [&lt;ffffffff81337553&gt;] ? security_file_ioctl+0x43/0x60
 [&lt;ffffffff812414a9&gt;] SyS_ioctl+0x79/0x90
 [&lt;ffffffff817a04ee&gt;] entry_SYSCALL_64_fastpath+0x12/0x71

Reported-by: Rodrigo Rivas Costa &lt;rodrigorivascosta@gmail.com&gt;
Reported-by: Clément VUCHENER &lt;clement.vuchener@gmail.com&gt;
Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=193741
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;</content>
</entry>
<entry>
<title>Input: uinput - fix crash when mixing old and new init style</title>
<updated>2017-02-01T18:33:11Z</updated>
<author>
<name>Dmitry Torokhov</name>
<email>dmitry.torokhov@gmail.com</email>
</author>
<published>2017-01-31T22:56:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=601bbbe0517303c9f8eb3d75e11d64efed1293c9'/>
<id>urn:sha1:601bbbe0517303c9f8eb3d75e11d64efed1293c9</id>
<content type='text'>
If user tries to initialize uinput device mixing old and new style
initialization (i.e. using old UI_SET_ABSBIT instead of UI_ABS_SETUP,
we forget to allocate input-&gt;absinfo and will crash when trying to send
absolute events:

        ioctl(ui, UI_DEV_SETUP, &amp;us);
        ioctl(ui, UI_SET_PHYS, "Test");

        ioctl(ui, UI_SET_EVBIT, EV_ABS);
        ioctl(ui, UI_SET_ABSBIT, ABS_X);
        ioctl(ui, UI_SET_ABSBIT, ABS_Y);
        ioctl(ui, UI_DEV_CREATE, 0);

Reported-by: Rodrigo Rivas Costa &lt;rodrigorivascosta@gmail.com&gt;
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=191811
Fixes: fbae10db0940 ("Input: uinput - rework ABS validation")
Reviewed-by: Benjamin Tissoires &lt;benjamin.tissoires@redhat.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;</content>
</entry>
<entry>
<title>miscdevice: Add helper macro for misc device boilerplate</title>
<updated>2016-08-31T12:12:35Z</updated>
<author>
<name>PrasannaKumar Muralidharan</name>
<email>prasannatsmkumar@gmail.com</email>
</author>
<published>2016-08-25T17:00:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ca75d601b5942e8cf5eed68f308be0526d0dac5d'/>
<id>urn:sha1:ca75d601b5942e8cf5eed68f308be0526d0dac5d</id>
<content type='text'>
Many modules call misc_register and misc_deregister in its module init
and exit methods without any additional code. This ends up being
boilerplate. This patch adds helper macro module_misc_device(), that
replaces module_init()/ module_exit() with template functions.

This patch also converts drivers to use new macro.

Change since v1:
Add device.h include in miscdevice.h as module_driver macro was not
available from other include files in some architectures.

Signed-off-by: PrasannaKumar Muralidharan &lt;prasannatsmkumar@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input</title>
<updated>2016-05-28T02:14:35Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2016-05-28T02:14:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ed2608faa0f701b1dbc65277a9e5c7ff7118bfd4'/>
<id>urn:sha1:ed2608faa0f701b1dbc65277a9e5c7ff7118bfd4</id>
<content type='text'>
Pull more input subsystem updates from Dmitry Torokhov:
 "Just a few more driver fixes; new drivers will be coming in the next
  merge window"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: pwm-beeper - fix - scheduling while atomic
  Input: xpad - xbox one elite controller support
  Input: xpad - add more third-party controllers
  Input: xpad - prevent spurious input from wired Xbox 360 controllers
  Input: xpad - move pending clear to the correct location
  Input: uinput - handle compat ioctl for UI_SET_PHYS
</content>
</entry>
</feed>
