Commit graph

23,931 commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult
ccfc4797cf miext: damage: use drawable pointer instead of list head pointer to avoid realloc() UAF
The original fix (*1) introduced a use-after-free vulnerability by caching a pointer
into a realloc()able privates array (pListHead). This fix replaces the pListHead pointer with
pListDrawable, storing the drawable pointer at insertion time and re-deriving the list head
at removal time via getDrawableDamageRef(), avoiding the realloc() UAF.

The fix:
1. Changes pListHead (DamagePtr *) to pListDrawable (DrawablePtr) in damagestr.h
2. Updates damageInsertDamage to store pDamage->pDrawable instead of the list head pointer
3. Updates damageRemoveDamage to take a DrawablePtr and re-derive the list head via getDrawableDamageRef()
4. Updates all call sites to pass the drawable pointer instead of the list head pointer
5. Fixes damagePixmapDestroy to pass the pixmap as the drawable

*1) da72833185

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-02 02:53:47 +02:00
Jeremy Huddleston Sequoia
a319ce535b damage: Unlink a damage from the list it was actually inserted on
DamageRegister() chooses which list a damage is linked onto via getDrawableDamageRef(), but DamageUnregister() and
damageSetWindowPixmap() re-derived that list at removal time.  For a window the answer depends on the window pixmap,
which changes while the damage is registered (Composite redirection, rootless drawing and Present flips all swap it), so
the removal could consult a different list than the one the damage was inserted onto.  It then silently found nothing --
DAMAGE_VALIDATE_ENABLE is off, so the diagnostic is compiled out -- and left an unregistered, often freed, damage linked
where damageRegionAppend() would later dereference its NULL pDrawable and crash.

Record the list head when linking a damage and always unlink from that, which also drops a use-after-free read of the
old window pixmap in damageSetWindowPixmap(): rootless frees its scratch pixmap before restoring the pre-drawing window
pixmaps, so the pixmap consulted there had already been destroyed.

Fixes: https://github.com/XQuartz/XQuartz/issues/406

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2277>
(cherry picked from commit da72833185)
(cherry picked from commit 07df8459788fa1f73ff173cb4dbd8233a69fddf4)
(cherry picked from commit 3df8dc189e3982038a8672639ab6bffbf6e32ad4)
2026-10-02 02:53:47 +02:00
Enrico Weigelt, metux IT consult
427470cead meson: only install dri3.h if building dri3 support
Reported-by: Thomas Klausner <wiz@gatalith.at>
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-01 19:28:51 +02:00
Jeremy Huddleston Sequoia
d8cee7e08b xkb: Guard XkbAdjustGroup() against a keymap with no groups
When every key in a keymap has zero groups, ctrls->num_groups is 0 and each out-of-range action here misbehaves.
XkbWrapIntoRange divides by zero, which is the reported crash.  XkbClampIntoRange is worse: it computes -1,
returns it through this function's unsigned type, and the callers truncate it into XkbStateRec's unsigned char
group fields as 255, after which XkbComputeCompatState() reads map->groups[255] out of a four element array and
reports what it finds to clients in the compat state of every core event.  The negative-group case adds zero
forever, wedging the server thread, in one path while it holds input_lock.  XkbComputeDerivedState() treats group
0 as out of range once num_groups is 0, so all of this is reachable from an ordinary key event.

XQuartz gets there because it asks for model "empty", whose keycodes file declares no key names, so a keymap
compiled at a client's request has no key definitions at all.

Guard the arithmetic itself and not just the places that compute num_groups: groups_wrap selects between these
actions and is client settable, and this is exported for DDXes that supply their own controls.

Fixes: https://github.com/XQuartz/XQuartz/issues/422
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2278>
(cherry picked from commit bdb14dce4b)
(cherry picked from commit b5ea5591d1f514d0eb0cc5f58052a24fd1b06b9e)
(cherry picked from commit eb420bff03b4ae05d00821482c9fcfaf32a2922d)
2026-10-01 19:01:38 +02:00
Lukáš Lipinský
cafe531326 Xi: byte-swap DeviceChanged valuator and scroll data
SDeviceChangedEvent left ValuatorClass.value and every ScrollClass-specific multi-byte field in server byte order. Swapped clients therefore received corrupt current values and scroll metadata.

Swap those fields and extend the protocol event conversion coverage to nonzero relative valuator values and both scroll directions and flags.

Signed-off-by: Lukáš Lipinský <18076-Mr-Tao@users.noreply.gitlab.freedesktop.org>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2291>
(cherry picked from commit cf91b97d6c)
(cherry picked from commit 7a7e9c66b17cd0d64d31fa19244f3e4eb162fed7)
(cherry picked from commit f9e486ad1d398fb8dcf48f88cd8923decd291c7c)
2026-10-01 19:00:26 +02:00
Lukáš Lipinský
9f1a06d0b5 Xi: byte-swap XIQueryDevice ScrollClass flags
SwapScrollInfo converted the other multi-byte ScrollClass fields but left flags in server byte order. Swap it as well and decode the field in the swapped-client protocol test so nonzero flags exercise the wire representation.

Signed-off-by: Lukáš Lipinský <18076-Mr-Tao@users.noreply.gitlab.freedesktop.org>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2291>
(cherry picked from commit 8033c4d93e)
(cherry picked from commit 2d1d0b67dc2119507f52e3dae96827b8946d0eca)
(cherry picked from commit db6f28acaa7c7d2a049a92396e1bc35b6f759d8a)
2026-10-01 18:55:18 +02:00
Lukáš Lipinský
b799d88a78 test: fail when a child terminates abnormally
When a later test child is killed by a signal, exit_code may still contain zero from the preceding child. Return EXIT_FAILURE explicitly so Meson cannot report a false success.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2293>
(cherry picked from commit 495ea74203)
(cherry picked from commit 21e4929c355df7f525d0d0299781ccb6daa83780)
(cherry picked from commit d9abd1140755adcee1e2c9ec6d53794fb276f8d1)
Signed-off-by: Lukáš Lipinský <18076-Mr-Tao@users.noreply.gitlab.freedesktop.org>
2026-10-01 18:53:50 +02:00
Jeremy Huddleston Sequoia
e84a8065c4 RegionValidate: Fix double free of badreg->data on the error path
RegionValidate() copies *badreg into ri[0].reg, so ri[0].reg.data aliases badreg->data. A later
RECTALLOC_BAIL() can realloc() that block and move it, updating ri[0].reg.data but not badreg->data. On
the bail path, freeing ri[0].reg.data and then calling RegionBreak(badreg) frees badreg->data a second
time, which by then is a stale pointer into memory already freed or reallocated to something else.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2281>
(cherry picked from commit 4ef1b4cd26)
(cherry picked from commit bb02769445b1a516f33b4855977cc227f0542cb7)
(cherry picked from commit bc0760d9514fe5f2d9e4f5287ab0318d45c32736)
2026-10-01 18:52:29 +02:00
Jeremy Huddleston Sequoia
d7e1c7e5c9 xkb: Keep the group counts of a loaded keymap in range
Clamp the count once per key and use it everywhere the key or the keymap is indexed with it, while still reading
every symbol the file claimed so that the stream stays in step and the symbol array is not left short.

At the other end, a symbols section in which no key defines any group leaves the count at the zero it was
allocated with.  This is how XQuartz's keyboard is initialized: model "empty" supplies a symbols section that
defines no keys, and a section that defines nothing is still a section, so XkbInitControls() sees XkmSymbolsMask
and skips its own single-group default.  The device only survives because DarwinKeyboardReloadHandler()
immediately pushes a core keymap that raises the count again.

Fixes: https://github.com/XQuartz/XQuartz/issues/422
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2278>
(cherry picked from commit 0c764d98ee)
(cherry picked from commit 173fe333e4c4cec65bf61427827e2f44262c29af)
(cherry picked from commit ea50d2225fb90686987bc45449a3b93decf0054c)
2026-10-01 18:19:22 +02:00
Jeremy Huddleston Sequoia
ba20d93aea xkb: Never recompute a keymap's group count down to zero
Both places that derive ctrls->num_groups from the widest key in the map can arrive at zero.  But a keymap in
which no key defines any symbols is legal, so ensure we declare at least one group.

Fixes: https://github.com/XQuartz/XQuartz/issues/422
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2278>
(cherry picked from commit aa0bc93d27)
(cherry picked from commit a3f4359f33e65d16037d010a875ef93ed8cc6dee)
(cherry picked from commit 8bb68f76e1940dea50e6c4182b45e8ee528cbe62)
2026-10-01 18:18:40 +02:00
Jeremy Huddleston Sequoia
88043a1944 xkb: Default to one group whenever a keymap reports none
XkbInitControls() had a fallback to ensure keymaps that defined no symbols at all still resulted in one group.
Extend this to cover the case where a keymap reports symbols but no groups.

Fixes: https://github.com/XQuartz/XQuartz/issues/422
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2278>
(cherry picked from commit 8e11715024)
(cherry picked from commit c9dd5aa9e505d65036c351c78cd74c5a6fc53535)
(cherry picked from commit 712c3e7497c90a0d9ad6f863abdd2e330623887d)
2026-10-01 17:36:35 +02:00
Daniel Monteiro
d9e71a6e3b xfree86: don't make a failed GPU screen ScreenInit fatal
InitOutput() calls FatalError() when AddGPUScreen() fails, taking
down the whole server even when the primary screen initialized
fine. The hotplug path (xf86platformAddDevice) already treats the
same failure as recoverable: it deletes the screen and carries on.

Do the same at init: log the failure, delete the screen, continue
with the remaining screens.

Seen in practice on a hybrid laptop where a runtime-suspended
secondary GPU fails to wake (kernel bug): the LightDM greeter's
Xorg dies for a GPU screen it never needed.

Closes: #1912

Signed-off-by: Daniel Monteiro <monteiroquiet@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2271>
(cherry picked from commit a5ec3570e1)
(cherry picked from commit 82fd237d12a5ddde62997198721583d826f11060)
(cherry picked from commit 195ff6b8900c5d845aa2d63b6fb1592afd7b78db)
2026-10-01 17:23:20 +02:00
Olivier Fourdan
dbca511268 test/pyxtest: cover unbounded DEVICE_RESOLUTION SwapLongs
Send a swapped ChangeDeviceControl/DEVICE_RESOLUTION with
num_valuators=255 and no valuator payload. Without the SProc length
check this overruns the request buffer; with it the server returns
BadLength.

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2285>
(cherry picked from commit ddf3edc368)
(cherry picked from commit 3ed09c52d4a9cfe85b5f9d2f64beac022d79b221)
(cherry picked from commit 3f8dfe0169d563e147872a659ff461b95eeea16b)
2026-10-01 17:17:14 +02:00
Enrico Weigelt, metux IT consult
1d4c4208ac ci: use release/** pattern for PR CI to cover future release branches 2026-10-01 15:07:53 +02:00
Enrico Weigelt, metux IT consult
41c06aa72e ci: restrict push CI to non-PR branches; PR CI only on master and release/* 2026-10-01 15:02:55 +02:00
Peter Hutterer
2b4933210f test/pyxtest: add PictFormInfo and QueryPictFormatsReply to render proto
Add structured reply parsers for the Render QueryPictFormats response,
replacing manual struct.unpack_from() with offset arithmetic.

Fixes: acbc46e708 ("pyxtest: add tests for the byteswapping patches")

Assisted-by: Claude:claude-opus-4-6
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2264>
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2026-10-01 14:56:24 +02:00
Enrico Weigelt, metux IT consult
71bf6fcdc6 ci: bump dragonflybsd-vm from v1.1.4 to v1.3.4
The DragonFlyBSD lane reports success without ever building. Measured in two
independent runs:

Run 36739123551 (failed overall, 18:25:20 -> 18:47:32, complete log):
  the guest-side shell was Killed twice (SIGKILL, OOM on the runner while a
  nested QEMU runs), and immediately after each kill the action still emitted
  ##[end-action ... outcome=success;conclusion=success]. No build ran in any
  of the three attempts: "meson" 0 occurrences, "running xserver build" 0.
  That is why attempts 1 and 2 were recorded as green.

Run 36763250919 (reported success, 19:11:48 -> 19:15:29, complete log):
  the build script started and meson setup completed ("Build targets in
  project"), then nothing: "Compiling C" 0, "Linking" 0, "meson install" 0.
  Conclusion: success.

So the lane swallows the exit code of the inner command. v1.1.4 is also twelve
tag releases behind; the newest is v1.3.4.

Not a host-load problem, which is why no load metric would have found it: in
run 36762972575 netbsd, freebsd, hurd, gentoo and the image job all succeeded
while dragonflybsd failed, on the same runner class at the same time.

Fixing this restores an actual signal rather than making a broken one louder.
Whether v1.3.4 also fixes the swallowed exit code is to be measured, not
assumed - that is what the CI run on this PR is for.

The other VM lanes are already current: freebsd floats on @v1 and is the most
reliable lane, netbsd was bumped to v1.5.0 when it broke the same way.

Signed-off-by: Enterprise <info@metux.net>
2026-10-01 13:31:15 +02:00
stefan11111
896a371146 kdrive/modesetting: Add hw cursor support
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
42bf0a3a4a kdrive/modesetting: Add options -notile -planar
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
d693532c49 kdrive: Set bitsPerRGB to 10 for depth 30 visuals
Leave smaller depth alone, the bitsPerRGB value
gets reported correctly for them

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
b22fb56545 kdrive/modesetting: Fix visual masks in msGlamorTileFront
This makes things way simpler

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
81101107a3 kdrive/modesetting: Create a mapped front first, have glamor only tile it
Simplifies things a bit

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
2041e599c0 kdrive/modesetting: Simplify modesetting_open
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
9ba6e9c291 kdrive/modesetting: Fix 24 bpp front
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
290db52322 kdrive/modesetting: Get RandR working again
Some issues accumulated when tiled buffers and modifiers were implemented

Rotations don't yet work with tiled buffers

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
c9fe32bbd4 kdrive/modesetting: Filter multi-plane modifiers
Same reason as xf86 modesetting

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
82e306ec61 kdrive/modesetting: Plug in modifier support
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
bd675f7b2f kdrive/modesetting: query renderable modifiers
Not doing anything with them yet.
In preparation for further work

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
0303ee076b kdrive/modesetting: Rename the glamor functions
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
346c4dff7e kdrive/modesetting: Split visual mask setting to a separate function
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
f79ed3f798 kdrive/modesetting: Split damage-tracking functions to their own file
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
8605faa8a9 kdrive/modesetting: Split RandR functions to their own file
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
92cafe5dee kdrive/modesetting: Split some functions to ms_util.c
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
114ba583a0 kdrive/modesetting: Split modesetting queries into a different file
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
8080cd8d9f kdrive: Don't limit refresh rate by default
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
1fd03c1c23 kdrive/modesetting: Fix non-shadow bpp
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
5c77631dd8 kdrive/modesetting: swab r-b channels for BGR depth 30 visuals on gles
`glamor_setup_formats` chooses `PIXMAN_x2b10g10r10` format for depth 30
pixmaps on gles.

If the front buffer is XBGR2101010 on gles, swap the r-b channels,
like we would with a cpu-mapped buffer.

As I understand it, we should also swap XRGB2101010 r-b channels on gles,
but for some reason not swapping them works.
This needs further investigating.

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
c179d7d061 kdrive/modesetting: Factor out bo swapping code fron RandR
Fixes a bug where on the fallback bo map path,
one would have to chang VT away and back to the X server
for the image to appear on screen.

May be useful for implementing page flipping in the future

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
ad65d972e0 kdrive/modesetting: Log the front buffer format and modifier
Progress report

Tested Xmodesetting on intel and nvidia, both with regular and swapped formats,
both with and without `-nogbm`, both with and without glamor.

Depths 30, 24, and 16 work both on intel and nvidia.

Depth 15 also works on nvidia, but the nvidia gbm backend
refuses to allocate a depth 15 bo.
Using the dumb gbm backend, an depth 15 bo can be allocated,
and it works.

Nvidia doesn't support depth 30 with RGB ordering, and depth 16 with BGR ordering.
Xmodesetting properly detects this and swaps the R-B channels.

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
be5f1a3a90 kdrive/modesetting: Add -swap option
Mostly intended for testing.

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
8630054692 kdrive/modesetting: Implement gamma support through RandR
Move the gamma-related stuff to a different file

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
ce1c470288 kdrive/modesetting: Implement DPMS support
Also some cosmetic changes

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
2cdafe5668 kdrive/modesetting: Tighten front buffer allocation checks/fallbacks
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
21bf97db7b kdrive/modesetting: Tile the front buffer
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
e0b6278f0a kdrive/modesetting: Try to use drmModeAddFB2{,WithModifiers}
Fall back to `drmModeAddFB` if that fails

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
07e44ba550 kdrive: Implement -videoTest option
The option was parsed, but not implemented

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
7679459a51 kdrive/modesetting: Move gbm functions to another file, support more formats
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
54b433043b kdrive/os/stub: Add a distinctive XInput name
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
95e1def6a4 kdrive/modesetting: Use the scanout video card for rendering
even when probed and not explcit

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00
stefan11111
89f3c725cd kdrive: Don't disable input devices if already disabled
Reverts and fixes 14912f8a09

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-10-01 13:30:12 +02:00