GNOME Bugzilla – Bug 778472
libinput >1.6 may request opening other files than /dev/input nodes
Last modified: 2017-02-16 12:51:24 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.
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().
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.
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().
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().
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
(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.
Attachment 345893 [details] pushed as 2d18b18 - backends: Allow opening /sys/ files on MetaLauncher