xserver/miext/sync
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Peter Hutterer 2a0c937439 sync: fix deletion of counters and fences
Both FreeCounter() and miSyncDestroyFence() iterate over the trigger list
and invoke the CounterDestroyed callback on each trigger.

The CounterDestroyed callback (e.g. SyncAwaitTriggerFired) may call
FreeResource/FreeAwait, which frees the SyncAwaitUnion containing all
SyncAwait structs in the same Await group.

When multiple conditions in a single Await reference the same sync
object (counter or fence), the first callback frees all SyncAwait
structs while subsequent trigger list nodes still reference them. On the
next iteration, reading ptl->next or ptl->pTrigger dereferences freed
memory, leading to a use-after-free.

We need separate fixes for separate issues here to fix this in one go
- use our null-terminated list macro to make sure our next pointer stays
  valid (the code accessed ptl->next after freeing it)
- update the list head before deleting the trigger, eventually this ends
  up being NULL anyway but meanwhile the list head is a valid list
  during CounterDestroyed
- check if we actually do have a trigger before dereferencing the
  callback
- Set all triggers to NULL if they are shared so we don't dereference
  potentially freed memory

This vulnerability was discovered by:
Anonymous working with TrendAI Zero Day Initiative

ZDI-CAN-30159 (miSyncDestroyFence), ZDI-CAN-30163 (FreeCounter)

Assisted-by: Claude:claude-opus-4-6
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2228>
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-06-03 17:49:13 +02:00
..
meson.build mi: sync: move over public SDK headers to include/ 2026-02-12 14:32:24 +01:00
misync.c sync: fix deletion of counters and fences 2026-06-03 17:49:13 +02:00
misync_priv.h miext: sync: drop useless CloseScreen wrapping 2025-06-12 16:43:17 +02:00
misyncfd.c drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
misyncshm.c drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00