wayland/src
Neil Roberts cf4f5995dc server: Add API to protect access to an SHM buffer
Linux will let you mmap a region of a file that is larger than the
size of the file. If you then try to read from that region the process
will get a SIGBUS signal. Currently the clients can use this to crash
a compositor because it can create a pool and lie about the size of
the file which will cause the compositor to try and read past the end
of it. The compositor can't simply check the size of the file to
verify that it is big enough because then there is a race condition
where the client may truncate the file after the check is performed.

This patch adds the following two public functions in the server API
which can be used wrap access to an SHM buffer:

void wl_shm_buffer_begin_access(struct wl_shm_buffer *buffer);
void wl_shm_buffer_end_access(struct wl_shm_buffer *buffer);

The first time wl_shm_buffer_begin_access is called a signal handler
for SIGBUS will be installed. If the signal is caught then the buffer
for the current pool is remapped to an anonymous private buffer at the
same address which allows the compositor to continue without crashing.
The end_access function will then post an error to the buffer
resource.

The current pool is stored as part of some thread-local storage so
that multiple threads can safely independently access separate
buffers.

Eventually we may want to add some more API so that compositors can
hook into the signal handler or replace it entirely if they also want
to do some SIGBUS handling.
2013-11-13 16:31:28 -08:00
..
.gitignore Add a public header for the version number 2012-04-12 17:54:44 -04:00
connection.c Add support for server-side language bindings 2013-08-19 16:23:08 -07:00
event-loop.c server: Make wl_object and wl_resource opaque structs 2013-07-02 15:52:47 -04:00
Makefile.am build: Add wayland-scanner.pc. 2013-07-03 16:38:12 -04:00
scanner.c scanner: Handle unrecognized invocation mode 2013-10-07 21:36:31 -07:00
scanner.mk Rename source subdir from wayland to src 2011-08-12 16:25:14 -04:00
wayland-client-uninstalled.pc.in build: add uninstalled pkg-config files 2012-05-29 10:09:59 -04:00
wayland-client.c client: Fix handling display->reader_count if poll fails 2013-09-25 10:11:20 -07:00
wayland-client.h wayland: Be consistent about #include-guard names 2013-10-21 14:39:06 -07:00
wayland-client.pc.in Export the Wayland protocol XML file 2013-09-21 21:48:56 -07:00
wayland-egl.h wayland: Be consistent about #include-guard names 2013-10-21 14:39:06 -07:00
wayland-os.c os: wrap accept4(SOCK_CLOEXEC) 2012-04-25 09:37:42 +03:00
wayland-os.h os: wrap accept4(SOCK_CLOEXEC) 2012-04-25 09:37:42 +03:00
wayland-private.h Add support for server-side language bindings 2013-08-19 16:23:08 -07:00
wayland-scanner-uninstalled.pc.in build: Add wayland-scanner.pc. 2013-07-03 16:38:12 -04:00
wayland-scanner.pc.in build: Add wayland-scanner.pc. 2013-07-03 16:38:12 -04:00
wayland-server-uninstalled.pc.in build: add uninstalled pkg-config files 2012-05-29 10:09:59 -04:00
wayland-server.c wayland-server: Fix a uninitialized warning from clang 2013-09-11 10:42:37 -07:00
wayland-server.h server: Add API to protect access to an SHM buffer 2013-11-13 16:31:28 -08:00
wayland-server.pc.in Export the Wayland protocol XML file 2013-09-21 21:48:56 -07:00
wayland-shm.c server: Add API to protect access to an SHM buffer 2013-11-13 16:31:28 -08:00
wayland-util.c Remove incorrect sanity-check from wl_map_insert_at 2013-06-05 17:45:47 -04:00
wayland-util.h utils: Document wl_container_of 2013-09-21 11:31:41 -07:00
wayland-version.h.in Add a public header for the version number 2012-04-12 17:54:44 -04:00