]> git.baikalelectronics.ru Git - kernel.git/commit
*: convert stream-like files -> stream_open, even if they use noop_llseek
authorKirill Smelkov <kirr@nexedi.com>
Wed, 19 Jun 2019 17:26:56 +0000 (20:26 +0300)
committerKirill Smelkov <kirr@nexedi.com>
Sun, 14 Jul 2019 13:09:19 +0000 (16:09 +0300)
commit1fa802501862625e9d3b6717a48ad26114e9fb8e
treeed4de6ffa008cb693aab0369ca485742014c4e50
parentf01ead29895ffadc21e68cc10ab8a440d84ec7e8
*: convert stream-like files -> stream_open, even if they use noop_llseek

This patch continues a6349d20e2ff (fs: stream_open - opener for
stream-like files so that read and write can run simultaneously without
deadlock) and d36205851114 (*: convert stream-like files from
nonseekable_open -> stream_open) and teaches steam_open.cocci to
consider files as being stream-like not only if they have
.llseek=no_llseek, but also if they have .llseek=noop_llseek.

This is safe to do: the comment about noop_llseek says

This is an implementation of ->llseek useable for the rare special case when
userspace expects the seek to succeed but the (device) file is actually not
able to perform the seek. In this case you use noop_llseek() instead of
falling back to the default implementation of ->llseek.

and in general noop_llseek was massively added to drivers in 321d382138a2
(llseek: automatically add .llseek fop) when changing default for NULL .llseek
from NOP to no_llseek with the idea to avoid breaking compatibility, if
maybe some user-space program was using lseek on a device without caring
about the result, but caring if it was an error or not.

Amended semantic patch produces two changes when applied tree-wide:

        drivers/hid/hid-sensor-custom.c:690:8-24: WARNING: hid_sensor_custom_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
        drivers/input/mousedev.c:564:1-17: ERROR: mousedev_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.

Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Jan Blunck <jblunck@suse.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Kirill Smelkov <kirr@nexedi.com>
drivers/hid/hid-sensor-custom.c
drivers/input/mousedev.c
scripts/coccinelle/api/stream_open.cocci