wayland/src
Duncan McIntosh 20fd3b3af9 wayland-shm: Check the size of sealed memory if ignoring SIGBUS handlers
In 11623e8f, SIGBUS handlers aren't set if F_SEAL_SHRINK is configured on
the memory. This helps avoid setting up handlers with cooperative clients;
however, if an application gives an incorrect size, the compositor would
access it anyways, figuring SIGBUS is impossible, and crash.

This can be fixed by simply removing the seal-checking logic and always
setting the signal handler. However, it seems that fstat can give the size
of the memfd, so we can check that the size we were told is within the
region. Since it's sealed to shrinking, it must never be shrunk in future,
so we can really (hopefully) ignore SIGBUS.

I was worried that fstat wasn't supported for this, but shm_overview(7) does
mention that it is a possible use.

The best solution would likely be avoiding SIGBUS entirely with
MAP_NOSIGBUS, but that hasn't been merged yet and wouldn't help systems
without it (e.g. with older kernels).

A proof-of-concept of this crash is attached with the merge request. Running
it with this patch gives an invalid-shm error, which is correct.

Signed-off-by: Duncan McIntosh <duncan82013@live.ca>
2021-11-04 09:02:19 +00:00
..
.gitignore ignore: Add *.dtd.embed 2016-03-10 22:24:20 -08:00
connection.c debug: Fix printing of new ids 2021-11-02 11:27:51 +00:00
embed.py build: replace assembly embedding with Python script 2021-05-10 22:08:45 +00:00
event-loop.c src: Add missing new lines to log messages 2021-05-07 11:07:54 +03:00
meson.build build: Include the Wayland minor version in libraries' ABI versions 2021-10-28 12:46:06 +00:00
scanner.c scanner: Use the new atomic marshal/destroy function 2021-08-07 11:53:23 +00:00
wayland-client-core.h client: Add new proxy marshalling functions with flags 2021-08-07 11:53:23 +00:00
wayland-client.c debug: Fix printing of new ids 2021-11-02 11:27:51 +00:00
wayland-client.h doc: Formalize file comment in wayland-client.h, wayland-server.h 2016-05-11 11:03:27 -07:00
wayland-os.c Detect FreeBSD versions with broken MSG_CMSG_CLOEXEC 2021-09-10 11:35:54 +00:00
wayland-os.h shm: Add mmap+memmove fallback if mremap() does not exist 2021-09-10 11:35:54 +00:00
wayland-private.h debug: Fix printing of new ids 2021-11-02 11:27:51 +00:00
wayland-server-core.h server: add wl_display getter for wl_global 2021-03-05 09:12:33 +00:00
wayland-server-private.h Move wl_priv_signal to wayland-server-private.h 2019-11-06 08:24:14 -06:00
wayland-server.c debug: Fix printing of new ids 2021-11-02 11:27:51 +00:00
wayland-server.h wayland-server: Finally remove deprecated struct wl_buffer definition 2018-07-25 12:08:16 -05:00
wayland-shm.c wayland-shm: Check the size of sealed memory if ignoring SIGBUS handlers 2021-11-04 09:02:19 +00:00
wayland-util.c util: Avoid undefined behaviour in for_each_helper 2021-07-21 11:42:42 +00:00
wayland-util.h util: fix compiler warning 2020-02-24 11:02:44 +00:00
wayland-version.h.in src: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-12 15:31:24 -07:00