<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/drivers/input/misc/uinput.c, branch v4.4.265</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.4.265</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.4.265'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2021-01-23T14:36:55Z</updated>
<entry>
<title>Input: uinput - avoid FF flush when destroying device</title>
<updated>2021-01-23T14:36:55Z</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.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=0cd7ca78a35976956292daf32bf7831e6c18753d'/>
<id>urn:sha1:0cd7ca78a35976956292daf32bf7831e6c18753d</id>
<content type='text'>
commit e8b95728f724797f958912fd9b765a695595d3a6 upstream.

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;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>Input: uinput - add compat ioctl number translation for UI_*_FF_UPLOAD</title>
<updated>2019-07-10T07:56:31Z</updated>
<author>
<name>Andrey Smirnov</name>
<email>andrew.smirnov@gmail.com</email>
</author>
<published>2019-05-23T19:55:26Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4b6818e02588eb6eee0d741106dd71248e7a6c07'/>
<id>urn:sha1:4b6818e02588eb6eee0d741106dd71248e7a6c07</id>
<content type='text'>
commit 7c7da40da1640ce6814dab1e8031b44e19e5a3f6 upstream.

In the case of compat syscall ioctl numbers for UI_BEGIN_FF_UPLOAD and
UI_END_FF_UPLOAD need to be adjusted before being passed on
uinput_ioctl_handler() since code built with -m32 will be passing
slightly different values. Extend the code already covering
UI_SET_PHYS to cover UI_BEGIN_FF_UPLOAD and UI_END_FF_UPLOAD as well.

Reported-by: Pierre-Loup A. Griffais &lt;pgriffais@valvesoftware.com&gt;
Signed-off-by: Andrey Smirnov &lt;andrew.smirnov@gmail.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>Input: uinput - handle compat ioctl for UI_SET_PHYS</title>
<updated>2016-06-08T01:14:32Z</updated>
<author>
<name>Ricky Liang</name>
<email>jcliang@chromium.org</email>
</author>
<published>2016-05-20T17:58:59Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=854d1c275baea33efabec4daf97f7d662cad6505'/>
<id>urn:sha1:854d1c275baea33efabec4daf97f7d662cad6505</id>
<content type='text'>
commit affa80bd97f7ca282d1faa91667b3ee9e4c590e6 upstream.

When running a 32-bit userspace on a 64-bit kernel, the UI_SET_PHYS
ioctl needs to be treated with special care, as it has the pointer
size encoded in the command.

Signed-off-by: Ricky Liang &lt;jcliang@chromium.org&gt;
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>Input: uinput - fix crash when using ABS events</title>
<updated>2015-09-21T16:32:41Z</updated>
<author>
<name>Dmitry Torokhov</name>
<email>dmitry.torokhov@gmail.com</email>
</author>
<published>2015-09-19T18:22:57Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=72d4736253af74147b1fa68145b2f4c61d1f37e1'/>
<id>urn:sha1:72d4736253af74147b1fa68145b2f4c61d1f37e1</id>
<content type='text'>
Commit b6d30968d86c45a7bb599eaca13ff048d3fa576c (Input: uinput - switch to
using for_each_set_bit()) switched driver to use for_each_set_bit().
However during initial write of the uinput structure that contains min/max
data for all possible axes none of them are reflected in dev-&gt;absbit yet
and so we were skipping over all of them and were not allocating absinfo
memory which caused crash later when driver tried to sens EV_ABS events:

&lt;1&gt;[   15.064330] BUG: unable to handle kernel NULL pointer dereference at 0000000000000024
&lt;1&gt;[   15.064336] IP: [&lt;ffffffff8163f142&gt;] input_handle_event+0x232/0x4e0
&lt;4&gt;[   15.064343] PGD 0
&lt;4&gt;[   15.064345] Oops: 0000 [#1] SMP

Fixes: b6d30968d86c45a7bb599eaca13ff048d3fa576c
Cc: stable@vger.kernel.org
Reported-by: Stephen Chandler Paul &lt;cpaul@redhat.com&gt;
Tested-by: Stephen Chandler Paul &lt;cpaul@redhat.com&gt;
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;</content>
</entry>
<entry>
<title>Input: uinput - switch to using for_each_set_bit()</title>
<updated>2015-07-09T18:19:25Z</updated>
<author>
<name>Anshul Garg</name>
<email>aksgarg1989@gmail.com</email>
</author>
<published>2015-07-09T17:18:22Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=b6d30968d86c45a7bb599eaca13ff048d3fa576c'/>
<id>urn:sha1:b6d30968d86c45a7bb599eaca13ff048d3fa576c</id>
<content type='text'>
Use for_each_set_bit to check for set bits in bitmap
as it is more efficient and compact.

Signed-off-by: Anshul Garg &lt;aksgarg1989@gmail.com&gt;
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;</content>
</entry>
<entry>
<title>Input: uinput - add UI_GET_VERSION ioctl</title>
<updated>2014-07-21T21:30:42Z</updated>
<author>
<name>David Herrmann</name>
<email>dh.herrmann@gmail.com</email>
</author>
<published>2014-07-21T00:27:09Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=ba4e9a61ad54c438d4c7b655e94e31f23a6fe13f'/>
<id>urn:sha1:ba4e9a61ad54c438d4c7b655e94e31f23a6fe13f</id>
<content type='text'>
This ioctl is the counterpart to EVIOCGVERSION and returns the
uinput-version the kernel was compiled with.

Reviewed-by: Peter Hutterer &lt;peter.hutterer@who-t.net&gt;
Signed-off-by: David Herrmann &lt;dh.herrmann@gmail.com&gt;
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;
</content>
</entry>
<entry>
<title>Input: uinput - uinput_validate_absbits() cleanup</title>
<updated>2014-07-21T21:28:21Z</updated>
<author>
<name>David Herrmann</name>
<email>dh.herrmann@gmail.com</email>
</author>
<published>2014-07-21T00:16:23Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=bcb898e5873430d8121eb8df07d5fbfb49134167'/>
<id>urn:sha1:bcb898e5873430d8121eb8df07d5fbfb49134167</id>
<content type='text'>
This moves basic checks and setup from uinput_setup_device() into
uinput_validate_absbits() to make it easier to use. This way, we can call
it from other places without copying the boilerplate code.

Reviewed-by: Peter Hutterer &lt;peter.hutterer@who-t.net&gt;
Signed-off-by: David Herrmann &lt;dh.herrmann@gmail.com&gt;
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;
</content>
</entry>
<entry>
<title>Input: uinput - add UI_GET_SYSNAME ioctl to retrieve the sysfs path</title>
<updated>2014-02-12T23:00:34Z</updated>
<author>
<name>Benjamin Tissoires</name>
<email>benjamin.tissoires@redhat.com</email>
</author>
<published>2014-01-31T01:20:24Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=e3480a61fca72d40d6dc4baaf37e94fcbfa95e19'/>
<id>urn:sha1:e3480a61fca72d40d6dc4baaf37e94fcbfa95e19</id>
<content type='text'>
uinput is used in the xorg-integration-tests suite and in the wayland
test suite. These automated tests suites create many virtual input
devices and then hook something to read these newly created devices.

Currently, uinput does not provide the created input device, which means
that we rely on an heuristic to guess which input node was created.
The problem is that is heuristic is subjected to races between different
uinput devices or even with physical devices. Having a way to retrieve
the sysfs path allows us to find without any doubts the event node.

Signed-off-by: Benjamin Tissoires &lt;benjamin.tissoires@redhat.com&gt;
Reviewed-by: David Herrmann &lt;dh.herrmann@gmail.com&gt;
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;
</content>
</entry>
<entry>
<title>Input: uinput - breaks by goto out in uinput_ioctl_handler</title>
<updated>2014-01-31T01:30:57Z</updated>
<author>
<name>Benjamin Tisssoires</name>
<email>benjamin.tissoires@redhat.com</email>
</author>
<published>2014-01-31T01:16:36Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9d51e801dba0c79ae979ef2f6928e402eb41009b'/>
<id>urn:sha1:9d51e801dba0c79ae979ef2f6928e402eb41009b</id>
<content type='text'>
The current implementation prevents us to add variable-length ioctl.
Use a bunch of gotos instead of break to allow us to do so.

No functional changes.

Signed-off-by: Benjamin Tisssoires &lt;benjamin.tissoires@redhat.com&gt;
Reviewed-by: David Herrmann &lt;dh.herrmann@gmail.com&gt;
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;
</content>
</entry>
<entry>
<title>Input: uinput - support injecting multiple events in one write() call</title>
<updated>2013-09-19T15:57:56Z</updated>
<author>
<name>Ryan Mallon</name>
<email>rmallon@gmail.com</email>
</author>
<published>2013-09-18T19:40:47Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=cbf0541374e2fcfdfdcaf8365c957a137eb9feea'/>
<id>urn:sha1:cbf0541374e2fcfdfdcaf8365c957a137eb9feea</id>
<content type='text'>
Rework the code in uinput_inject_event so that it matches the code in
evdev_write and allows injecting more than one event, or zero events.

Signed-off-by: Ryan Mallon &lt;rmallon@gmail.com&gt;
Signed-off-by: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;
</content>
</entry>
</feed>
