A modular Wayland compositor library
Find a file
Simon Ser 6d63871f05 linux_drm_syncobj_v1: fix use-after-free in surface_commit_destroy()
surface_commit_destroy() accesses a field from
struct wlr_linux_drm_syncobj_surface_v1, however that struct may have
been free'd earlier:

    ==1103==ERROR: AddressSanitizer: heap-use-after-free on address 0x7cdef7a6e288 at pc 0x7feefaac335a bp 0x7ffc4de8f570 sp 0x7ffc4de8f560
    READ of size 8 at 0x7cdef7a6e288 thread T0
        #0 0x7feefaac3359 in surface_commit_destroy ../subprojects/wlroots/types/wlr_linux_drm_syncobj_v1.c:195
        #1 0x7feefaac34cd in surface_commit_handle_surface_destroy ../subprojects/wlroots/types/wlr_linux_drm_syncobj_v1.c:211
        #2 0x7feefbd194cf in wl_signal_emit_mutable (/usr/lib/libwayland-server.so.0+0x84cf) (BuildId: b9664217748f523995e3f855fa197cf8e59942d1)
        #3 0x7feefaa52b22 in surface_handle_resource_destroy ../subprojects/wlroots/types/wlr_compositor.c:730
        #4 0x7feefbd1bb9f  (/usr/lib/libwayland-server.so.0+0xab9f) (BuildId: b9664217748f523995e3f855fa197cf8e59942d1)
        #5 0x7feefaa46a18 in surface_handle_destroy ../subprojects/wlroots/types/wlr_compositor.c:65
        #6 0x7feef89afac5  (/usr/lib/libffi.so.8+0x7ac5) (BuildId: d5e3b0d8921923f35438adefa9f864745abc5e90)
        #7 0x7feef89ac76a  (/usr/lib/libffi.so.8+0x476a) (BuildId: d5e3b0d8921923f35438adefa9f864745abc5e90)
        #8 0x7feef89af06d in ffi_call (/usr/lib/libffi.so.8+0x706d) (BuildId: d5e3b0d8921923f35438adefa9f864745abc5e90)
        #9 0x7feefbd17531  (/usr/lib/libwayland-server.so.0+0x6531) (BuildId: b9664217748f523995e3f855fa197cf8e59942d1)
        #10 0x7feefbd1cd2f  (/usr/lib/libwayland-server.so.0+0xbd2f) (BuildId: b9664217748f523995e3f855fa197cf8e59942d1)
        #11 0x7feefbd1b181 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xa181) (BuildId: b9664217748f523995e3f855fa197cf8e59942d1)
        #12 0x7feefbd1d296 in wl_display_run (/usr/lib/libwayland-server.so.0+0xc296) (BuildId: b9664217748f523995e3f855fa197cf8e59942d1)
        #13 0x555bf0a55a40 in server_run ../sway/server.c:615
        #14 0x555bf0a4a654 in main ../sway/main.c:376
        #15 0x7feef9227674  (/usr/lib/libc.so.6+0x27674) (BuildId: 4fe011c94a88e8aeb6f2201b9eb369f42b4a1e9e)
        #16 0x7feef9227728 in __libc_start_main (/usr/lib/libc.so.6+0x27728) (BuildId: 4fe011c94a88e8aeb6f2201b9eb369f42b4a1e9e)
        #17 0x555bf0a03f54 in _start (/home/leo/code/stuff/sway/build/sway/sway+0x390f54) (BuildId: e3d4e653af1aa0885f0426c403e16fc87c086d33)

    0x7cdef7a6e288 is located 8 bytes inside of 176-byte region [0x7cdef7a6e280,0x7cdef7a6e330)
    freed by thread T0 here:
        #0 0x7feefb71f79d in free /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:51
        #1 0x7feefaac29f1 in surface_destroy ../subprojects/wlroots/types/wlr_linux_drm_syncobj_v1.c:84
        #2 0x7feefaac2e47 in surface_handle_resource_destroy ../subprojects/wlroots/types/wlr_linux_drm_syncobj_v1.c:143
        #3 0x7feefbd1bb9f  (/usr/lib/libwayland-server.so.0+0xab9f) (BuildId: b9664217748f523995e3f855fa197cf8e59942d1)
        #4 0x7feefaac2a12 in surface_handle_destroy ../subprojects/wlroots/types/wlr_linux_drm_syncobj_v1.c:89
        #5 0x7feef89afac5  (/usr/lib/libffi.so.8+0x7ac5) (BuildId: d5e3b0d8921923f35438adefa9f864745abc5e90)

    previously allocated by thread T0 here:
        #0 0x7feefb7205dd in calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:74
        #1 0x7feefaac4abd in manager_handle_get_surface ../subprojects/wlroots/types/wlr_linux_drm_syncobj_v1.c:313
        #2 0x7feef89afac5  (/usr/lib/libffi.so.8+0x7ac5) (BuildId: d5e3b0d8921923f35438adefa9f864745abc5e90)

Fix this by storing the struct wlr_surface in the field.

Closes: https://github.com/swaywm/sway/issues/8917
2025-10-17 09:05:53 +00:00
.builds ci: fix VKMS lookup after faux bus migration 2025-10-16 11:04:25 +02:00
.gitlab/issue_templates Add GitLab issue template 2023-10-08 11:29:13 +00:00
backend render: introduce bt.1886 transfer function 2025-10-04 18:13:37 +05:30
docs render: add WLR_RENDERER_FORCE_SOFTWARE env var 2024-12-22 21:37:57 +00:00
examples fullscreen-shell: remove 2025-03-30 01:15:09 +03:00
include render: introduce bt.1886 transfer function 2025-10-04 18:13:37 +05:30
protocol protocols: sync with wlr-protocols, apply non-breaking updates and doc improvements 2025-09-10 09:50:09 -04:00
render render: introduce bt.1886 transfer function 2025-10-04 18:13:37 +05:30
subprojects build: add Meson wrap manifests for our dependencies 2024-12-22 21:24:03 +00:00
tinywl tinywl: stop generating xdg-shell header 2025-08-27 14:21:23 -04:00
types linux_drm_syncobj_v1: fix use-after-free in surface_commit_destroy() 2025-10-17 09:05:53 +00:00
util util/box.c: use 1/256 instead of 1/65536 in wlr_box_closest_point() 2025-10-16 13:46:27 +00:00
xcursor xcursor/wlr_xcursor: properly clean xcursor in case of realloc failure in load_callback 2024-04-18 16:47:07 +02:00
xwayland xwayland: fix assertion failure in wlr_xwayland_shell_v1 2025-09-16 13:59:06 +08:00
.editorconfig editorconfig: Unset maximum line length for .git 2024-05-25 07:54:58 +00:00
.gitignore git: fix incorrect subprojects ignore in .gitignore 2025-03-23 13:24:15 +01:00
.gitlab-ci.yml ci: generate and publish HTML documentation 2025-01-31 15:27:03 +00:00
.mailmap .mailmap: add myself 2024-08-05 19:32:24 +03:00
CONTRIBUTING.md CONTRIBUTING.md: mention listener list assertions 2025-01-20 16:17:12 +03:00
LICENSE license: add copyright line for all contributors 2023-07-05 10:27:50 +02:00
meson.build fixes: add implementation 2025-08-13 20:41:21 +00:00
meson.options render/allocator: add udmabuf allocator 2024-12-22 21:37:57 +00:00
README.md backend/drm: use libdisplay-info to parse EDID 2023-02-28 14:44:02 +00:00
release.sh Add release script 2025-09-22 10:12:43 -04:00
wlroots.syms build: simplify version script 2021-06-17 11:03:21 +02:00

wlroots

Pluggable, composable, unopinionated modules for building a Wayland compositor; or about 60,000 lines of code you were going to write anyway.

  • wlroots provides backends that abstract the underlying display and input hardware, including KMS/DRM, libinput, Wayland, X11, and headless backends, plus any custom backends you choose to write, which can all be created or destroyed at runtime and used in concert with each other.
  • wlroots provides unopinionated, mostly standalone implementations of many Wayland interfaces, both from wayland.xml and various protocol extensions. We also promote the standardization of portable extensions across many compositors.
  • wlroots provides several powerful, standalone, and optional tools that implement components common to many compositors, such as the arrangement of outputs in physical space.
  • wlroots provides an Xwayland abstraction that allows you to have excellent Xwayland support without worrying about writing your own X11 window manager on top of writing your compositor.
  • wlroots provides a renderer abstraction that simple compositors can use to avoid writing GL code directly, but which steps out of the way when your needs demand custom rendering code.

wlroots implements a huge variety of Wayland compositor features and implements them right, so you can focus on the features that make your compositor unique. By using wlroots, you get high performance, excellent hardware compatibility, broad support for many wayland interfaces, and comfortable development tools - or any subset of these features you like, because all of them work independently of one another and freely compose with anything you want to implement yourself.

Check out our wiki to get started with wlroots. Join our IRC channel: #wlroots on Libera Chat.

A variety of wrapper libraries are available for using it with your favorite programming language.

Building

Install dependencies:

  • meson
  • wayland
  • wayland-protocols
  • EGL and GLESv2 (optional, for the GLES2 renderer)
  • Vulkan loader, headers and glslang (optional, for the Vulkan renderer)
  • libdrm
  • GBM (optional, for the GBM allocator)
  • libinput (optional, for the libinput backend)
  • xkbcommon
  • udev (optional, for the session)
  • pixman
  • libseat (optional, for the session)
  • hwdata (optional, for the DRM backend)
  • libdisplay-info (optional, for the DRM backend)
  • libliftoff (optional, for the DRM backend)

If you choose to enable X11 support:

  • xwayland (build-time only, optional at runtime)
  • libxcb
  • libxcb-render-util
  • libxcb-wm
  • libxcb-errors (optional, for improved error reporting)

Run these commands:

meson setup build/
ninja -C build/

Install like so:

sudo ninja -C build/ install

Contributing

See CONTRIBUTING.md.