input: Send unique keymap file descriptors to clients
authorDerek Foreman <derekf@osg.samsung.com>
Wed, 28 Jun 2017 17:17:46 +0000 (12:17 -0500)
committerDerek Foreman <derekf@osg.samsung.com>
Fri, 17 Aug 2018 14:25:24 +0000 (09:25 -0500)
commit76829fc4eaea329d2a525c3978271e13bd76c078
treefe9e08bf3b47505ca21010f2b54d01159963c0e5
parentf8f7fd69df5bf318b2da9ec6ce964ac676eb2e29
input: Send unique keymap file descriptors to clients

Client may map any file descriptor opened for writing with PROT_WRITE
themselves.  On linux, even a read-only file descriptor to an unlinked
file can be re-opened with write permission through /proc/self/fd.

The only way to prevent this is to create a memfd which
is subsequently write-sealed.  Unfortunately this prevents clients
from mapping with MAP_SHARED, which is already in widespread usage.

To isolate and protect the keymap, whilst allowing MAP_SHARED clients
to continue to work, use a unique file descriptor for each
wl_keyboard resource.

Reviewed-by: Daniel Stone <daniels@collabora.com>
libweston/compositor.h
libweston/input.c