Commit graph

24,082 commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult
dbe1efc284 xaverius: expand registry tests for tombstone and DIX publication
Add real-header registry tests covering tombstone transitions, module-role finalize/shutdown ownership, and DIX-backed PhysicalDevice publication/duplicate-publish behavior using actual registry and resource APIs.
2026-11-11 16:04:23 +01:00
Enrico Weigelt, metux IT consult
5c061f5f4d xaverius: integrate registry unit tests into test harness
Replace shadow-type standalone xaverius registry test with meson-built tests using real XAverius headers in test/tests, covering identity comparison, ordering keys, module-role ownership hooks, and registration/binding lifecycle paths.
2026-11-11 15:02:42 +01:00
Enrico Weigelt, metux IT consult
67fffbc25f xaverius: fix registry identity/ordering, role ownership, and XID lifecycle
Correct registration ordering-key generation from canonical copied identity, enforce non-truncating ordering-key creation, balance ModuleRole retain/release across binding allocation/failure paths with centralized binding cleanup, and persist/publish PhysicalDevice XIDs with duplicate-publish protection and shutdown cleanup.
2026-11-11 15:02:41 +01:00
Enrico Weigelt, metux IT consult
18499fad39 xaverius: Add unit tests for Registry ABI and core logic
- New test/xaverius-registry-test.c covering:
  * ModuleRoleDescriptor struct_size/abi_version validation
  * Identity comparison (PCI, DRM, UUID, cross-class)
  * Canonical ordering key generation and comparator
  * Descriptor size validation

- test/meson.build: Add xaverius-registry-test executable (conditionally
  built when xaverius enabled; test registration currently disabled due
  to meson link ordering with xorg_link).
2026-11-10 19:12:05 +01:00
Enrico Weigelt, metux IT consult
40c9268d5a xaverius: Implement PhysicalDevice Registry Stages 1-4 core logic
- Deep copy all four nested operation tables (buffer_memory,
  shader_pipeline, commands, synchronization) in xaverius_binding_alloc()
  with atomic rollback on allocation failure.

- Add caller_refcount to XaveriusPhysicalDevice for proper
  XaveriusPhysicalDeviceRelease() semantics. Exact replay increments
  refcount; Release decrements it.

- Fix XaveriusPhysicalDeviceDIXDestroy(): no longer modifies
  XaveriusPhysicalDeviceType (resource type ID). Only acknowledges
  resource destruction.

- Implement canonical ordering key per spec: identity_class:pci_or_drm:
  device_uuid:driver_uuid:owner_key with bytewise lexicographic comparator.

- Remove tautological sizeof() checks in registration; use field-by-field
  xaverius_identity_equal() for identity comparison.

- Fix XaveriusRegistryFini() to properly free deep-copied operation tables
  via new xaverius_binding_free() helper.

- Fix XaveriusRegistryRemoveDeviceBackendBinding() to use binding_free.

- ModuleRoleCreate() now stores module_lease from descriptor.

- Add internal validation functions: xaverius_module_role_descriptor_valid(),
  xaverius_identity_equal(), xaverius_identity_has_pci().
2026-11-10 19:11:34 +01:00
Enrico Weigelt, metux IT consult
7d45545914 xaverius: Fix ABI v1 compliance and OpenBSD build
- Remove duplicate typedef of XaveriusPhysicalDevice from xaverius_intern.h
  (forward declaration only; full typedef remains in xaverius_priv.h).
  Fixes OpenBSD clang -Wtypedef-redefinition error.

- Update ModuleRoleDescriptor and internal ModuleRole struct to use
  XaveriusModuleRole* instead of void* for retain/release/quiesce callbacks.
  quiesce_module_role now returns XaveriusModuleQuiescenceResult per ABI v1.

- Add ModuleRoleAdmission and ModuleRoleQuiesceState enums to intern.h.

- Fix static assertion macro in xaverius_proto.h to properly expand __LINE__
  via XAVERIUS_STATIC_ASSERT_4 helper (was already present but confirmed).
2026-11-10 19:10:40 +01:00
Enrico Weigelt, metux IT consult
8ecaf8e2b8 xaverius: Fix Meson build for -Dxorg=false
The test/meson.build referenced xorg_inc variable which is only defined when build_xorg=true.
This caused meson configuration to fail when building with -Dxorg=false -Dxaverius=true.

Fixed by making xorg_inc conditional on build_xorg option in test/meson.build.
The xaverius-registry-test target was already removed in a previous commit.

Fixes: -Dxorg=false -Dxaverius=true build configuration
2026-11-10 15:35:45 +01:00
Enrico Weigelt, metux IT consult
5bdc8a576b xaverius: Fix ABI v1 compliance and OpenBSD build failure
- Fix query_physical_snapshot callback signature to match normative ABI v1:
  (XaveriusDeviceBackendBinding *, XaveriusPhysicalDeviceSnapshot *)
  instead of (void *, void *, uint64_t *)

- Fix ModuleRoleDescriptor function pointer types to use void * parameters
  matching normative ABI v1 specification

- Add XaveriusPhysicalDeviceSnapshot struct definition

- Fix XaveriusDeviceBackendRegistration to remove owner_key/owner_key_size
  and use owner_role/owner_role_generation from ModuleRole

- Fix XaveriusDeviceBackendRegistration to use identity (not identity_evidence)
  and owner_role/owner_role_generation instead of module_role_generation

- Fix ModuleRole struct: remove is_permanent, role_userdata; use void* function
  pointers matching normative ABI v1; add XaveriusModuleLease *module_lease

- Fix registry.c: Fix identity evidence handling, binding allocation, snapshot
  callback, DIX destructor, registry finalization, and binding removal

- Remove misleading comparator test that duplicated production logic
- Fix Meson build for -Dxorg=false by removing xorg_inc dependency

Build: Ubuntu/SDK -Werror builds pass
Tests: 153/154 passing (1 pre-existing failure in signal_logging_test)

Signed-off-by: Defiant <defiant@x11libre.org>
2026-11-10 13:29:37 +01:00
Enrico Weigelt, metux IT consult
bb77f1c42b xaverius: Fix OpenBSD C99 static assertion token concatenation
Fix the C99 fallback for XAVERIUS_STATIC_ASSERT by adding a third-level
macro to force expansion of __LINE__ before token concatenation.

The previous implementation used __LINE__ directly in the macro argument,
which doesn't expand before token concatenation, causing all static
assertions to generate the same identifier 'xav_static_assert___LINE__'
instead of unique line numbers.

Fixed by adding an intermediate macro XAVERIUS_STATIC_ASSERT_3 that
forces __LINE__ expansion before passing to the helper.

Build: green (-Werror)
Tests: 153/154 passing (1 pre-existing failure in signal_logging_test unrelated)

Signed-off-by: Defiant <defiant@x11libre.org>
2026-11-10 10:57:09 +01:00
Enrico Weigelt, metux IT consult
2153d7988b xaverius: add physical device registry
DDX drivers can register their physical Vulkan devices here.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-11-10 10:30:18 +01:00
Enrico Weigelt, metux IT consult
5d6a07fe62 xaverius: initialize property name atoms
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-11-10 10:30:18 +01:00
Enrico Weigelt, metux IT consult
ce0ff3d249 xaverius: add screen private structure and core init
* add screen private structures for xaverius
* DDX drivers can attach themselves into Xaverius stack and install
  their xaverius operation callbacks via XaveriusScreenInit()

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-11-10 10:30:18 +01:00
Enrico Weigelt, metux IT consult
6312baee38 Xaverius: add QueryVersion request
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-11-10 10:30:18 +01:00
Enrico Weigelt, metux IT consult
926afe9f94 xaverius: add wire protocol defines
This header contains the wire protocol defines and could also
be shared with clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-11-10 10:30:18 +01:00
Enrico Weigelt, metux IT consult
95fe729c6b WIP: enable Xaverius build by default (NOMERGE)
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-11-10 10:30:18 +01:00
Enrico Weigelt, metux IT consult
3d2b7a4027 Xaverius: add trivial extension stub
This only registers the extension, but nothing else than a trivial stub.
Enable building it via passing -Dxaverius=true to meson.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-11-10 10:30:18 +01:00
Enrico Weigelt, metux IT consult
6fc7af13d1 .github: cygwin: install python39-lxml
gen_gl_wrappers.py imports lxml.etree at build time, but Cygwin CI only
installed python312-lxml (for Python 3.12) while the default Python is
python39. Add python39-lxml so the import succeeds under Cygwin.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-11-10 10:22:48 +01:00
Enrico Weigelt, metux IT consult
ee4bb3f96e xfree86: int10: remove unused/obsolete dprint()
Not used anymore, so no need to keep it around any longer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-11-02 14:16:03 +01:00
Enrico Weigelt, metux IT consult
63379b4871 xfree86: int10: drop never used SHOW_ALL_DEVICES code pathes
These code pathes have never been actually used, thus no need to
carry them around for any longer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-11-02 14:14:20 +01:00
Enrico Weigelt, metux IT consult
483a1722f9 xfree86: int10: drop obsolete vm86 backend
* didn't compile since 2014 (commit 21b216ad6)
* based on vm86(), which is only availble on Linux i386/i686
* obsoleted by x86emu

Thus no need to carry around broken code pathes any longer.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-27 18:11:33 +01:00
Enrico Weigelt, metux IT consult
2545199fd8 xfree86: int10: remove some unused defines
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-27 17:23:31 +01:00
Enrico Weigelt, metux IT consult
07fa547b67 xfree86: int10: drop ancient remains of some DX/UX workaround
It seems that ancient DG/UX systems needed some special workarounds,
which of we only have some remains left that are never compiled.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-27 17:19:21 +01:00
Enrico Weigelt, metux IT consult
146a76a6c1 xfree86: int10: add define X86_CARRY_MASK
add a define with proper name instead of using raw literal value.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-27 16:43:25 +01:00
Enrico Weigelt, metux IT consult
722929bf50 xfre86: int10: drop obsolete REG macro definition
Not used anywhere.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-27 16:04:55 +01:00
Enrico Weigelt, metux IT consult
809696d4ee xfree86: int10: drop mode dead code
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-27 15:22:07 +01:00
Enrico Weigelt, metux IT consult
2ebd277a6d xfree86: drop some dead code
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-27 12:33:38 +01:00
Peter Hutterer
a8192aa709 Xi: add bounds check for barrier events in input_constrain_cursor
input_constrain_cursor() writes barrier hit and leave events into the
InputEventList buffer without checking how many slots remain.
The buffer is allocated by the DDX at GetMaximumEventsNum() (100) entries
and may contain one raw event already. A client can create more than 100
pointer barriers, pre-arm them as released via XIBarrierReleasePointer,
and then trigger a single pointer motion that crosses all barriers
simultaneously. The leave event loop iterates every hit barrier and
writes one event per barrier, overflowing the 100-slot buffer.

In an ideal world we'd change the InternalEvent* pointer to a struct
that contains allocated size, number of events and the pointer itself
but we're crossing public APIs here and that requires an ABI bump.

So we make do with cutting off the number of barrier events at 64 which
should be low enough to not trigger the issue. However, for the 100+
barrier case this means we only send BarierHit events, not BarrierRelease.
Potentially leaving a client stuck.

We mitigate that problem by simply refusing to create more than 32
barriers per screen (which on its own would also fix the issue, but hey,
'doppelt gemoppelt' as they say).

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

ZDI-CAN-31938

CVE-2026-93519

Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2341>
(cherry picked from commit 1f42cc1f00)
2026-10-20 21:11:11 +02:00
Peter Hutterer
4cec8f8089 dix: remove passive grabs referencing a device on removal
Passive grabs (GrabRec) store raw DeviceIntPtr values for both the
grabbed device and the modifier device without any lifetime management.
When a device is removed via XIRemoveMaster, CloseDevice() frees the
device struct, but leaves dangling pointers in grab->modifierDevice
for any grab that used this device.

Subsequent pointer events trigger CheckPassiveGrab() which dereferences
the dangling modifierDevice pointer for XI grabs (the CORE and XI2 paths
reassign it, but the XI path does not).

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

ZDI-CAN-31832

CVE-2026-93516

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2341>
(cherry picked from commit be57263415)
2026-10-20 21:11:11 +02:00
Peter Hutterer
cede1a7f95 Xi: validate modifier values in ProcXIPassiveUngrabDevice
ProcXIPassiveUngrabDevice() passes client-supplied modifier values
directly to DeletePassiveGrabFromList() without validating them.

DeletePassiveGrabFromList() may reach DeleteDetailFromMask() which uses
BITCLEAR(mask, modifier). The mask is allocated as 8 Mask words (256
bits). A modifier value > 255 causes BITCLEAR to index mask[modifier>>5]
past the allocation, resulting in a controlled single-bit-clear at an
attacker-chosen heap offset.

Add the same modifier validation that CheckGrabValues() uses: reject
modifiers that are not XIAnyModifier and have bits set outside
AllModifiersMask.

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

ZDI-CAN-32366

CVE-2026-93523

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2341>
(cherry picked from commit 37a1847a60)
2026-10-20 21:11:11 +02:00
Mario Kleiner
81e6f606a1 modesetting: Fix RandR output leasing while TearFree is enabled.
Since commit a94dd9536 ("modesetting: add support for TearFree page flips"),
whenever TearFree and PageFlip is simultaneously enabled (which is the
default now), the driver does enable DRM universal plane support, just
as when atomic modesetting is enabled.

Leasing RandR / DRM outputs with universal planes enabled requires
also adding the drm_plane object to the set of leased objects,
otherwise the drmModeCreateLease() ioctl will fail.

Adding a drm_plane object under this condition was omitted, so fix
this omission, and thereby fix RandR output leasing.

Fixes: a94dd9536 ("modesetting: add support for TearFree page flips")
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2332>
(cherry picked from commit f37bd8de26)
2026-10-20 19:58:05 +02:00
Peter Hutterer
9e3b288abf Fix remaining ruff check issues
Two if conditions compressed into one.
Two open() marked as ignored by SIM115 (use context manager for opening files)
because it'd require too much restructuring.
And one open() ... close()  changed to a context manager, the diff
is the reindentation of everything between open and close.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2327>
(cherry picked from commit eb9292efdb)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2026-10-20 19:56:53 +02:00
Peter Hutterer
d6de666503 Ruff check --fix --unsafe-fixes across the tree
Only affecting two files and these are the straightforward changes.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2327>
(cherry picked from commit 2c53e65004)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2026-10-20 19:56:53 +02:00
Peter Hutterer
c3b028aee8 Run ruff format against the whole source tree
Only two files that needed changes anyway, might as well enforce this.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2327>
(cherry picked from commit 6aa23cf642)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2026-10-20 19:56:53 +02:00
Peter Hutterer
51b140b4ad config: remove the fdi2iclass.py script
This is still Python2 which has been EOL for many moons now. The script
dates back to 2010 and we've well and truly moved on from using fdi files
to using xorg.conf snippets.

If in the last 16 years you somehow didn't manage to port the fdi
snippets, the git history will provide you with this file on request.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2327>
(cherry picked from commit f8af92cac4)
2026-10-20 19:56:53 +02:00
Peter Hutterer
bae088ccbd xkb: fix CheckKeySyms overwriting request-range symsPerKey entries
CheckKeySyms() has two loops: the first processes keys in the SetMap
request range, the second fills in any missing keys from the existing
map.

The indexing between the two was inconsistent: the first loop
uses a zero-based index + req->firstKeySym, the second loop used it just
as zero-based index.

Example:
   req->firstKeySym = 50
   req->nKeySyms = 10

  i goes from 0 to 10,
  loop 1 checks [50, 60), changes the width but finishes with i at 10.
  loop 2 then runs over [10, 255(, copying the old keymap width

The second loop overwrites the new widths with the width of the
existing keymap. The subsequent SetKeySyms worked on the new width
and may write fewer actions than the map width.

A subsequent XkbGetMap request would then read XkbKeyNumActions()
entries (derived from the new wider key_sym_map.width) from the shorter
action allocation, causing an out-of-bounds heap read. The overread
bytes would be copied into the GetMap reply and sent back to the client,
producing a bounded heap information disclosure.

This vulnerability was discovered by:
  WONJOON HWANG (@joon1337) working with TrendAI Zero Day Initiative

ZDI-CAN-32408

CVE-2026-93524

Assisted-by: Claude:claude-opus-4-6
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2341>
(cherry picked from commit cea71d0273)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2026-10-20 19:54:36 +02:00
Peter Hutterer
c5247a4185 xkb: widen size_syms, num_syms, size_acts, num_acts to unsigned int
Fields in XkbClientMapRec and XkbServerMapRec that denote size/num
and are unsigned short can result in truncations. For example
when XkbResizeKeyType() computes the new size_syms value as
(nTotal * 15) / 10, the result may be implicitly truncated to 16
bits on assignment. This causes an undersized calloc allocation, and the
subsequent copy loop writes based on the actual (untruncated) key count,
resulting in a heap buffer overflow. A similar truncation may happen
in XkbResizeKeySyms() and XkbResizeKeyActions().

Widen the fields from unsigned short to unsigned int. These are internal
server structures, not wire protocol types.

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

ZDI-CAN-31834

CVE-2026-93518

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Assisted-by: Claude:claude-opus-4-6
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2341>
(cherry picked from commit 89101a6c66)
2026-10-20 19:54:36 +02:00
Peter Hutterer
2822958bbf xkb: allocate names->keys to MAP_LENGTH in XkbAllocNames
Commit a3171732d ("xkb: Always use MAP_LENGTH keymap size") converted
most XKB allocation functions to use MAP_LENGTH (256) instead of
max_key_code + 1. It also removed the per-array reallocarray() calls in
XkbChangeKeycodeRange(), replacing them with a memset up to MAP_LENGTH.
However, XkbAllocNames() was missed and still allocates names->keys to
max_key_code + 1.

When a keycodes component with max_key_code < 255 is loaded (e.g.
sun(type6) with max_key_code=132) and then a SetMap request extends
maxKeyCode to 255, XkbChangeKeycodeRange() memsets names->keys from
max_key_code to MAP_LENGTH-1, writing past the undersized allocation.

Fix by allocating names->keys to MAP_LENGTH, consistent with all other
keymap arrays after a3171732d.

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

ZDI-CAN-31941

CVE-2026-93520

Fixes: a3171732da ("xkb: Always use MAP_LENGTH keymap size")

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Assisted-by: Claude:claude-opus-4-6
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2341>
(cherry picked from commit b941a473e0)
2026-10-20 19:54:36 +02:00
Peter Hutterer
a0f5e66caa xkb: NULL text pointer after free in _CheckSetDoodad error path
_CheckSetDoodad() allocates doodad->text.text via _GetCountedString()
and then attempts to allocate doodad->text.font. If the font string
allocation fails (e.g. because the font string length extends past
the request boundary), the error handler frees doodad->text.text but
does not NULL the pointer. The doodad was already added to the geometry
by XkbAddGeomDoodad() before the string allocations, so when
XkbFreeGeometry() runs cleanup, _XkbClearDoodad() frees the same
dangling pointer again, resulting in a double-free.

NULL the pointer after freeing it to prevent the double-free.

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

ZDI-CAN-31221

CVE-2026-88812

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Assisted-by: Claude:claude-opus-4-6
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2341>
(cherry picked from commit 0d1b1b0bad)
2026-10-20 19:54:36 +02:00
Mikhail Dmitrichenko
37f43dc86a xkb: reject incomplete keymaps in GetKbdByName
XkmReadFile() allocates an XkbDesc before it reads the individual XKM
sections, so a section read failure leaves a non-NULL but only partially
initialized description behind.

ReadXkmKeyTypes() does not report such a failure at all. When
XkbAllocClientMap() fails it returns the number of bytes read so far,
which is positive, so XkmReadFile() takes the section for successfully
read and clears it from the mask of sections it reports as missing.

ProcXkbGetKbdByName() in turn only checks that the description it got
back is non-NULL before setting rep.loaded. It can therefore install a
description that has neither a client map nor controls, and
XkbCopyControls() then dereferences those and crashes the server.

Return -1 from ReadXkmKeyTypes() when the client map cannot be
allocated, and only report a keymap as loaded once rep.found covers
every component in fneed. Decide whether to update the actions from
rep.loaded rather than from the requested load flag, so that an
incomplete description is not handled as a successfully loaded map.

The keymap the device already had stays active when the compiled XKM
cannot be read completely.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2304>
(cherry picked from commit 6a4fb12019)
2026-10-20 19:51:15 +02:00
Mikhail Dmitrichenko
3bb0f25410 xkb: use ssize_t for XKM byte counts
The ReadXkm* section readers return the number of bytes they consumed,
or -1 when they give up. That contract was spelled as int, while the
counters accumulating their results were a mix of int and unsigned, and
XkmGetCARD8/16/32() took the counter by reference as an int *.

XkmReadFile() also returns an unsigned, but that value is a bitmask of
the sections it could not read, not a byte count. Keeping byte counts in
unsigned variables right next to it makes the two easy to confuse, and
the confusion has a concrete cost: XkmReadFile() kept the readers'
results in an unsigned tmp, so the -1 that every one of the seven
readers it dispatches to can return became UINT_MAX. That passed the
tmp > 0 test below, and the section which had just failed to read was
marked as defined and cleared from the mask of sections reported as
missing.

Use ssize_t, the usual type for "a number of bytes, or -1 on failure",
for every byte count in this file: the section readers' return type, the
local counters, the counter XkmGetCARD8/16/32() take by reference, and
the return values of XkmSkipPadding() and XkmGetCountedString(). An
unsigned in this file now only ever denotes a bitmask, and a failing
section reader is no longer taken for a successful one.

ReadXkmKeyTypes() used a single tmp both for byte counts and as the
in/out element count handed to XkmInsureTypedSize(), which needs an
int *. That second use gets its own variable.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2304>
(cherry picked from commit bad7edcab0)
2026-10-20 19:51:15 +02:00
Peter Hutterer
edfab509bd glamor: size tmp_bits buffer for source coordinate range in upload_boxes
glamor_upload_boxes() allocates the tmp_bits buffer (used for 24-bit to
32-bit depth conversion) based on the destination pixmap height, but
indexes it using source coordinates (y1 - dy_dst + dy_src). When the
source is taller than the destination, the source-relative offset
exceeds the destination height, causing writes past the buffer end.

Size the buffer to account for the source coordinate mapping:
byte_stride * (pixmap->drawable.height - dy_dst + dy_src). This
ensures the buffer covers the full range of source rows that will be
accessed during the upload.

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

ZDI-CAN-32361

CVE-2026-93522

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Assisted-by: Claude:claude-opus-4-6
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2341>
(cherry picked from commit ad26c26bf7)
2026-10-20 19:49:20 +02:00
Peter Hutterer
5d3b8520ec present: unlink notifies from window list in present_clear_window_notifies
When a window is destroyed, present_clear_window_notifies()
does not remove the notify list node from the window. The notify
may then be freed as part of the window_priv, leaving dangling
pointers in place.

When the vblank owning the notify is later torn down,
present_free_window_notify() calls xorg_list_del() which
writes through these dangling pointers (use-after-free write).

This happens when Present cross-window notifies are used: a
PresentPixmap on window A can reference window B as a notify target.
An untriggered wait_fence keeps the vblank alive so that B can be
destroyed first, creating the dangling-pointer window.

Fix this by calling the free function we have (and moving the window
reset into that function too). present_clear_window_notifies is only
called from one place anyway.

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

ZDI-CAN-31830

CVE-2026-93515

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Assisted-by: Claude:claude-opus-4-6
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2341>
(cherry picked from commit 1b6955c310)
2026-10-20 19:49:20 +02:00
Peter Hutterer
02359bf013 glx: validate dataBytes against cmdlen in RenderLarge first request
__glXDisp_RenderLarge() allocates the large command buffer based on
cmdlen (from hdr->length, the total command size embedded in the
payload), but copies dataBytes (from req->dataBytes, the payload size
of the current sub-request) into it. The existing length check only
validates that the X11 request length is consistent with dataBytes,
not that dataBytes fits within the cmdlen-sized buffer.

A malicious client can set hdr->length to a small value (e.g. 12 bytes)
while sending a large dataBytes (up to ~256KB or more with
BIG-REQUESTS), causing the memcpy to overflow the cmdlen-sized buffer.

Add a check that dataBytes <= cmdlen before the buffer allocation and
copy on the first request.

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

ZDI-CAN-31833

CVE-2026-93517

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Assisted-by: Claude:claude-opus-4-6
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2341>
(cherry picked from commit 2abe4632d7)
2026-10-20 19:49:20 +02:00
Olivier Fourdan
84d53bf2f0 miext/sync: Handle SIGBUS from truncated shm fences
A client can truncate the shared memory backing a DRI3/xshmfence sync
fence and cause SIGBUS when the server accesses it.

Register the mapping with busfault and wrap xshmfence accesses with
sigsetjmp so truncation unwinds safely, then discard the mapping while
keeping the fence XID.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Assisted-by: AI
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/work_items/1911
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2270>
(cherry picked from commit cd083d9659)
2026-10-20 19:47:40 +02:00
Olivier Fourdan
e4b68f9248 os: Add busfault_set_jmp() for SIGBUS unwind
Allow callers to arm a sigjmp_buf on a registered mapping so the
SIGBUS handler can siglongjmp instead of remapping and retrying the
faulting instruction.

Needed when the mapping contains objects that are unsafe to resume
on after a replace.

This is preparation work for the next commit where that mechanism is
used.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Assisted-by: AI
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2270>
(cherry picked from commit 7a0b3e2197)
2026-10-20 19:47:40 +02:00
Peter Hutterer
5fd95d2754 pyxtest: abstract the present xclients
Use the same fixture style as we do for other extensions.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2325>
(cherry picked from commit cd79f876b1)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2026-10-20 19:46:28 +02:00
Kevin.Li
2fb3d5391c glamor: use highp for fill_pos UVs on GLES
Problem:
On a 2K (e.g. 2560x1440) display, WPS Office for Linux (Qt) shows
corrupted text and broken vertical lines on the right side of a
maximized window when the UI is updated by mouse movement (e.g.
hover/scroll refreshing labels). The same controls on the left side
are fine. The issue does not appear at 1080p, without glamor, or when
using desktop OpenGL shaders (non-GLES).

Root cause:
Xwayland GBM n-buffering CopyArea's window pixmap into the present
pixmap via glamor_copy (FBO texture blit). UVs are computed as
(offset + pixel) * (1/width, 1/height). GLES fragment shaders default
to mediump (~10-bit relative precision), so on wide pixmaps UVs near
the right edge can be off by about a pixel; with GL_NEAREST this
shows as shifted/broken glyphs and edges. Desktop OpenGL has no
default mediump precision qualifier, so the same shader path is fine.

Fix:
Force highp only on fillpos uniforms/ins/outs. Keep the global
mediump default for other fragment math.

Change-Id: If747516bdf787e0383b42e3579acfeab30a7cb1c
Signed-off-by: Kevin.Li <kevin.li@cixtech.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2315>
(cherry picked from commit 2b9ce9f6c6)
2026-10-20 19:46:16 +02:00
Kiyoshi Spreclerg
3a7005b67c composite: fix inverted cw->damaged in compReportDamage()
Also use `false` instead of `FALSE` in compWindowUpdate() for the bool field.

Fixes: 4a30260387 ("composite: use 'bool' instead of 'Bool' in CompClientWindowRec")
Signed-off-by: Kiyoshi Spreclerg <kiyoshi_pip@protonmail.com>
2026-10-19 13:10:03 +02:00
stefan11111
29a6b17197 kdrive/modesetting: pass the gbm device to glamor
Don't have it open another one

This fixes a segfault when the render card is different from
the scanout card, and glamor uses the fast gbm import path.

If https://github.com/X11Libre/xserver/issues/2645
applies to Xmodesetting, this probably fixes it.

This is also a resource usage optimization,
since glamor doesn't allocate another gbm device
when Xmodesetting already allocates a perfectly usable one.

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-19 13:09:25 +02:00
stefan11111
fbde8700f8 glamor/glamor_egl: Add support for passing gbm devices to glamor
Instead of having glamor_egl create the gbm device, let the ddx create
it and pass it to glamor.

This allows for saving some resources and for fixing a
bug on amd (if it still happens)

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-19 13:09:25 +02:00