Public bug reported:

Xwayland 24.1.10 in 26.04 aborts the X server with a NULL dereference in
damage_report() (hw/xwayland/xwayland-window.c:321). Xwayland dies and
every X11 client on the session loses its display.

Two error-tracker buckets reach the same instruction, both fully
attributed to 2:24.1.10-1 on 26.04 (200/200 samples each):

* A: https://errors.ubuntu.com/problem/971e76bf570af413691b6ecd0ea36dae54a88e82
  158/week. Background paint during client teardown / logout:
  damage_report -> damageRegionAppend -> damageDamageBox ->
  damagePolyFillRect -> miPaintWindow <- miClearToBackground <-
  compFreeClientSubwindows <- KillAllClients

* C: https://errors.ubuntu.com/problem/a5376eb1e3699d8a5bf85e7465554057264221fb
  100/week. DBE buffer swap, i.e. reachable during normal use:
  damage_report -> damageRegionAppend -> damageDamageBox ->
  damageCopyArea <- miDbeSwapBuffers <- ProcDbeSwapBuffers

Both abort with "xwl_window = 0x0" at the same instruction.

== Cause ==

Commit 34934c37d6a (in 24.1.10) restored register_damage() in
xwl_realize_window() before ensure_surface_for_window(). When
ensure_surface_for_window() returns NULL the damage hook stays
registered but no xwl_window exists for the window.

ensure_surface_for_window() returns NULL in rootless mode whenever
window->redirectDraw != RedirectDrawManual. That is not only "before a
WM redirects": Composite implicitly automatic-redirects a window whose
visual is an alternate visual (depth 32 / ARGB), so such a window is
realised with redirectDraw == RedirectDrawAutomatic, realise fails, but
the window is still viewable and damaged (non-empty winSize/borderClip).
The first damage report then dereferences the NULL xwl_window.

Any depth-32 window created while the WM has not manually redirected
the root (WM starting up, or gone/crashed) hits this as soon as it is
mapped; the map-time background paint is enough. The A and C stacks are
just two other callers that damage the same window later (teardown
background paint, DBE swap).

== Fix ==

Upstream commit d346a6dec0c98ef3aba4e4c776c19aabc4621740 ("xwayland:
Avoid NULL pointer dereference in damage_report()", Olivier Fourdan,
2026-04-22), MR !2190, backported as !2191, closes upstream
https://gitlab.freedesktop.org/xorg/xserver/-/work_items/1886.

8 insertions / 4 deletions in hw/xwayland/xwayland-window.c: early
"if (!xwl_window) return;" in damage_report() plus unregister_damage()
on the failed-realize path in xwl_realize_window().

First released in xwayland 24.1.11. Present in 26.10 (24.1.14) and
27.04 (24.1.15). 26.04 is the only affected supported release: it ships
2:24.1.10-1, which has no Debian patches at all, and has never had an
Xwayland update since release.

== Reproduction (headless, deterministic, no root) ==

Reproduced 2026-12-04 against the distribution binary /usr/bin/Xwayland
2:24.1.10-1 with matching ddebs symbols, private XDG_RUNTIME_DIR and
DISPLAY=:98; the live session was not touched.

1. miniwl: small Wayland compositor providing wl_compositor, wl_shm,
   wl_output and xdg_wm_base.
2. Xwayland :98 -rootless -noreset -ac against it.
3. crashtest argb: create a 1920x1080 depth-32 (ARGB) window and map it.

Xwayland aborts on the XMapWindow request at
xwayland-window.c:321, xwl_window = 0x0:

  #0 damage_report
  #3 damagePolyFillRect
  #4 miPaintWindow
  #5 miWindowExposures
  #6 miHandleValidateExposures
  #7 MapWindow

Variants (same harness):
* "crashtest argb nobg nopaint dbe" gives the exact bucket C stack
  (ProcDbeSwapBuffers -> miDbeSwapBuffers -> damageCopyArea -> ...).
* "crashtest argb nobg subwin subchild teardown" gives the bucket A
  caller (FreeClientResources -> compFreeClientSubwindows -> ...).
All variants reproduced 3/3.

The Wayland compositor log shows no create_surface at all, i.e.
ensure_surface_for_window() never succeeded for the window.

Attachments: harness tarball and the three gdb backtraces.

== SRU ==

Targeted upstream stable fix already shipped in 24.1.11 through 24.1.15,
one file, no ABI or behaviour change, no new build dependencies.

Proposed version: 2:24.1.10-1ubuntu0.2 on top of the current
2:24.1.10-1ubuntu0.1 (which only adds fix-tablet-input.patch). Debdiff
attached; ubuntu-sponsors subscribed.

Severity: session denial of service (Xwayland aborts and every X11
client is killed), no privilege boundary crossing, so this belongs in
-updates rather than -security.

== Test plan ==

1. With 2:24.1.10-1ubuntu0.1 run the harness above and observe the
   abort in damage_report().
2. With 2:24.1.10-1ubuntu0.2 the same steps must leave Xwayland running;
   the depth-32 window maps and works.
3. Session smoke test: log in to GNOME/Wayland, run an X11 client doing
   DBE swaps, log out and back in with X11 clients open; no Xwayland
   abort.
4. After release, the two error-tracker buckets should fall to zero.

== SRU template ==

[ Impact ]

Xwayland 24.1.10 in 26.04 aborts the X server with a NULL dereference
in damage_report(). It happens for a window whose Wayland surface
creation failed - in the field, a depth-32 (ARGB) window realised while
no manual compositor redirect is in effect, e.g. while the session's WM
is starting up, restarting or gone. The next damage report (map-time
background paint, teardown paint, DBE swap) dereferences the missing
xwl_window. Every X11 client on the session loses its display. Two
error-tracker buckets, 158/week and 100/week, both 200/200 samples on
2:24.1.10-1/26.04. 26.04 is the only supported release still affected.

[ Test Plan ]

1. On 2:24.1.10-1ubuntu0.1, run the attached headless harness (miniowl,
   Xwayland :98 -rootless -noreset -ac, then map a 1920x1080 depth-32
   window) and observe Xwayland abort at xwayland-window.c:321 with
   xwl_window = 0x0.
2. On 2:24.1.10-1ubuntu0.2 the same steps must leave Xwayland running
   and the window usable; repeat with the DBE-swap and teardown
   variants in the harness.
3. Session smoke test: log in to GNOME/Wayland, run an X11 client that
   uses DBE swaps, log out and back in with X11 clients open.
4. After release: both error-tracker buckets should fall to zero.

[ Where problems could occur ]

The change only adds an early return when xwl_window is NULL and
unregisters the damage hook on the failed-realise path. A window whose
Wayland surface could not be created stops emitting damage reports,
which is the intent; nothing changes for windows that realise normally.
It is the upstream fix (d346a6dec), also shipped in 24.1.11 through
24.1.15 (upstream default/stable branches) and already present in 26.10
and 27.04, so it has release exposure outside 26.04.

[ Other Info ]

Debdiff is against 24.1.10-1ubuntu0.1 (the current resolute-proposed
version, which only carries the tablet fix) and adds one patch:
8 insertions, 4 deletions in hw/xwayland/xwayland-window.c. Upstream
commit d346a6dec0c98ef3aba4e4c776c19aabc4621740, MR !2190, backport
!2191, closes upstream issue #1886. No ABI or behaviour change for
correctly realised windows, no new build dependencies. Session DoS, no
privilege boundary, so -updates rather than -security.

** Affects: xwayland (Ubuntu Resolute)
     Importance: Medium
         Status: In Progress


** Tags: desktop-needs-sru resolute

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2190874

Title:
  xwayland 24.1.10: NULL dereference in damage_report() kills the X
  server

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/resolute/+source/xwayland/+bug/2190874/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to