aboutsummaryrefslogtreecommitdiffstats
path: root/tests/client-test.c
Commit message (Collapse)AuthorAgeFilesLines
* Mitigate UAF crashes due to wl_client_destroy reentrancyThomas Lukaszewicz2024-02-231-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are situations in which a call into wl_client_destroy() can result in a reentrant call into wl_client_destroy() - which results in UAF / double free crashes. For example, this can occur in the following scenario. 1. Server receives a message notifying it that a client has disconnected (WL_EVENT_HANGUP [1]) 2. This beings client destruction with a call to wl_client_destroy() 3. wl_client_destroy() kicks off callbacks as client-associated resources are cleaned up and their destructors and destruction signals are invoked. 4. These callbacks eventually lead to an explicit call to wl_display_flush_clients() as the server attempts to flush events to other connected clients. 5. Since the client has already begun destruction, when it is reached in the iteration the flush fails wl_client_destroy() is called again [2]. This patch guards against this reentrant condition by removing the client from the display's client list when wl_client_destroy() is first called. This prevents access / iteration over the client after wl_client_destroy() is called. In the example above, wl_display_flush_clients() will pass over the client currently undergoing destruction and the reentrant call is avoided. [1] https://gitlab.freedesktop.org/wayland/wayland/-/blob/8f499bf4045f88f3a4b4b0a445befca467bebe20/src/wayland-server.c#L342 [2] https://gitlab.freedesktop.org/wayland/wayland/-/blob/8f499bf4045f88f3a4b4b0a445befca467bebe20/src/wayland-server.c#L1512 Signed-off-by: Thomas Lukaszewicz [thomaslukaszewicz@gmail.com](mailto:thomaslukaszewicz@gmail.com)
* server: add wl_client_get_user_data/wl_client_set_user_dataSebastian Wick2024-02-151-0/+15
| | | | | | | | | | | | | | | | The only way to attach some data to a wl_client seems to be setting up a destroy listener and use wl_container_of. Let's make it straight forward to attach some data. Having an explicit destroy callback for the user data makes managing the user data lifetime much more convenient. All other callbacks, be they wl_resource request listeners, destroy listeners or destructors, or wl_client destroy listeners, can assume that the wl_client user data still exists if it was set. Otherwise making that guarantee would be complicated. Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com> Signed-off-by: Sebastian Wick <sebastian@sebastianwick.net>
* tests: Ensure resource vs. client destroy handler orderDaniel Stone2022-10-201-1/+31
| | | | | | | | Make sure that the client destroy handler runs strictly before the resource destroy handler, which runs strictly before the client late-destroy handler. Signed-off-by: Daniel Stone <daniels@collabora.com>
* wayland-server: Add wl_client_add_destroy_late_listenerDaniel Stone2022-10-201-0/+24
| | | | | | | | | | A late-destroy listener for a client is called after all the client's resources have been destroyed and the destroy callbacks emitted. This lives in parallel to the existing client destroy listener, called immediately before the client's objects get destroyed. Signed-off-by: Daniel Stone <daniels@collabora.com> Fixes: wayland/wayland#207
* tests: Use bool for client testDaniel Stone2022-10-201-4/+4
| | | | | | A 0/1-only int is a bool. Signed-off-by: Daniel Stone <daniels@collabora.com>
* Use wl_container_of internallyMichael Forney2019-06-051-1/+1
| | | | | | | | | Rather than have two versions of the macro with slightly different interfaces, just use wl_container_of internally. This also removes use of statement expressions, a GNU C extension. Signed-off-by: Michael Forney <mforney@mforney.org>
* tests: Update boilerplate from MIT X11 license to MIT Expat licenseBryce Harrington2015-06-121-16/+19
| | | | | Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* server: Make wl_object and wl_resource opaque structsKristian Høgsberg2013-07-021-1/+1
| | | | | | | | | | With the work to add wl_resource accessors and port weston to use them, we're ready to make wl_resource and wl_object opaque structs. We keep wl_buffer in the header for EGL stacks to use, but don't expose it by default. In time we'll remove it completely, but for now it provides a transition paths for code that still uses wl_buffer. Reviewed-by: Jason Ekstrand<jason@jlekstrand.net>
* tests: Include wayland-private.h for container_ofKristian Høgsberg2012-10-211-0/+1
|
* tests: fix make check for out-of-tree buildsDylan Noblesmith2012-06-301-1/+1
| | | | | | | | | | It was failing with missing include files. While here, destroy the ugly "../src/..." include paths used in the tests that was just hacking around this problem in the Makefile: sed -i s/..\\/src\\/// tests/*.c
* server: Add client destroy signalKristian Høgsberg2012-04-131-0/+87