After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 778472 - libinput >1.6 may request opening other files than /dev/input nodes
libinput >1.6 may request opening other files than /dev/input nodes
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: wayland
unspecified
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2017-02-10 23:06 UTC by Carlos Garnacho
Modified: 2017-02-16 12:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
backends: Allow opening /sys/ files on MetaLauncher (1.01 KB, patch)
2017-02-10 23:08 UTC, Carlos Garnacho
none Details | Review
backends: Allow opening /sys/ files on MetaLauncher (2.28 KB, patch)
2017-02-15 22:36 UTC, Carlos Garnacho
none Details | Review
backends: Allow opening /sys/ files on MetaLauncher (2.28 KB, patch)
2017-02-15 22:42 UTC, Carlos Garnacho
committed Details | Review

Description Carlos Garnacho 2017-02-10 23:06:19 UTC
Starting with libinput >=1.6 and kernel >=4.9, libinput may request opening /sys/ files with O_RDONLY flags in order to access device led state. This is eg. the case for tablet pads.

We should allow MetaLauncher to open those, in order to avoid the imminent warning and possible libinput misbehavior.
Comment 1 Carlos Garnacho 2017-02-10 23:08:29 UTC
Created attachment 345495 [details] [review]
backends: Allow opening /sys/ files on MetaLauncher

libinput may want to access those for fetching LED status, as those are
requested readonly, just forward the request to plain open().
Comment 2 Rui Matos 2017-02-14 15:43:24 UTC
Review of attachment 345495 [details] [review]:

::: src/backends/native/meta-launcher.c
@@ +223,3 @@
+  /* Allow readonly access to sysfs */
+  if (g_str_has_prefix (path, "/sys/") && flags == O_RDONLY)
+    return open (path, flags, S_IRUSR);

The mode argument is only needed to create files (i.e. when flags includes O_CREAT or O_TMPFILE).

On device_close we'll hand this fd to logind which will probably fail.
Comment 3 Carlos Garnacho 2017-02-15 22:36:07 UTC
Created attachment 345892 [details] [review]
backends: Allow opening /sys/ files on MetaLauncher

libinput may want to access those for fetching LED status, as those are
requested readonly, just forward the request to plain open().
Comment 4 Carlos Garnacho 2017-02-15 22:42:05 UTC
Created attachment 345893 [details] [review]
backends: Allow opening /sys/ files on MetaLauncher

libinput may want to access those for fetching LED status, as those are
requested readonly, just forward the request to plain open().
Comment 5 Rui Matos 2017-02-16 12:26:34 UTC
Review of attachment 345893 [details] [review]:

with the second comment fixed, this looks fine

::: src/backends/native/meta-launcher.c
@@ +225,3 @@
+  if (g_str_has_prefix (path, "/sys/"))
+    {
+      fd = open (path, flags, S_IRUSR);

any particular reason you pass the mode argument to open() ? from my reading of open(2) it only makes sense when creating new files.

@@ +226,3 @@
+    {
+      fd = open (path, flags, S_IRUSR);
+      g_hash_table_add (self->sysfs_fds, GINT_TO_POINTER (fd));

we shouldn't add -1 to the hash table in case open() fails
Comment 6 Carlos Garnacho 2017-02-16 12:48:22 UTC
(In reply to Rui Matos from comment #5)
> Review of attachment 345893 [details] [review] [review]:
> 
> with the second comment fixed, this looks fine
> 
> ::: src/backends/native/meta-launcher.c
> @@ +225,3 @@
> +  if (g_str_has_prefix (path, "/sys/"))
> +    {
> +      fd = open (path, flags, S_IRUSR);
> 
> any particular reason you pass the mode argument to open() ? from my reading
> of open(2) it only makes sense when creating new files.

You're right, removed it locally.

> 
> @@ +226,3 @@
> +    {
> +      fd = open (path, flags, S_IRUSR);
> +      g_hash_table_add (self->sysfs_fds, GINT_TO_POINTER (fd));
> 
> we shouldn't add -1 to the hash table in case open() fails

Oops, indeed.

Pushing with these two fixes.
Comment 7 Carlos Garnacho 2017-02-16 12:51:19 UTC
Attachment 345893 [details] pushed as 2d18b18 - backends: Allow opening /sys/ files on MetaLauncher