Commit graph

18058 commits

Author SHA1 Message Date
Olivier Fourdan
38efdcada1 xserver 21.1.22
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2178>
2026-04-14 15:12:24 +02:00
Olivier Fourdan
e8674488a6 xkb: Add more _XkbCheckRequestBounds()
Similar to the recent fixes, add more _XkbCheckRequestBounds() to the
functions that loop over the request data, i.e.:

 * CheckKeySyms()
 * CheckKeyActions()
 * CheckKeyBehaviors()
 * CheckVirtualMods()
 * CheckKeyExplicit()
 * CheckVirtualModMap()
 * _XkbSetMapChecks()

All these are static functions so we can add the client to the parameters
without breaking any API.

See also:
CVE-2026-34003, ZDI-CAN-28736, CVE-2026-34002, ZDI-CAN-28737

v2: Check for "nSyms != 0" in CheckKeySyms() to avoid false positives.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit d38c563fab)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2178>
2026-04-14 15:12:24 +02:00
Olivier Fourdan
905194d1fa xkb: Add additional bound checking in CheckKeyTypes()
The function CheckKeyTypes() will loop over the client's request but
won't perform any additional bound checking to ensure that the data
read remains within the request bounds.

As a result, a specifically crafted request may cause CheckKeyTypes() to
read past the request data, as reported by valgrind:

  == Invalid read of size 2
  ==    at 0x5A3D1D: CheckKeyTypes (xkb.c:1694)
  ==    by 0x5A6A9C: _XkbSetMapChecks (xkb.c:2515)
  ==    by 0x5A759E: ProcXkbSetMap (xkb.c:2736)
  ==    by 0x5BF832: SProcXkbSetMap (xkbSwap.c:245)
  ==    by 0x5C05ED: SProcXkbDispatch (xkbSwap.c:501)
  ==    by 0x4A20DF: Dispatch (dispatch.c:551)
  ==    by 0x4B03B4: dix_main (main.c:277)
  ==    by 0x428941: main (stubmain.c:34)
  ==  Address is 30 bytes after a block of size 28,672 in arena "client"
  ==
  == Invalid read of size 2
  ==    at 0x5A3AB6: CheckKeyTypes (xkb.c:1669)
  ==    by 0x5A6A9C: _XkbSetMapChecks (xkb.c:2515)
  ==    by 0x5A759E: ProcXkbSetMap (xkb.c:2736)
  ==    by 0x5BF832: SProcXkbSetMap (xkbSwap.c:245)
  ==    by 0x5C05ED: SProcXkbDispatch (xkbSwap.c:501)
  ==    by 0x4A20DF: Dispatch (dispatch.c:551)
  ==    by 0x4B03B4: dix_main (main.c:277)
  ==    by 0x428941: main (stubmain.c:34)
  ==  Address is 2 bytes after a block of size 28,672 alloc'd
  ==    at 0x4848897: realloc (vg_replace_malloc.c:1804)
  ==    by 0x5E357A: ReadRequestFromClient (io.c:336)
  ==    by 0x4A1FAB: Dispatch (dispatch.c:519)
  ==    by 0x4B03B4: dix_main (main.c:277)
  ==    by 0x428941: main (stubmain.c:34)
  ==
  == Invalid write of size 2
  ==    at 0x5A3AD7: CheckKeyTypes (xkb.c:1669)
  ==    by 0x5A6A9C: _XkbSetMapChecks (xkb.c:2515)
  ==    by 0x5A759E: ProcXkbSetMap (xkb.c:2736)
  ==    by 0x5BF832: SProcXkbSetMap (xkbSwap.c:245)
  ==    by 0x5C05ED: SProcXkbDispatch (xkbSwap.c:501)
  ==    by 0x4A20DF: Dispatch (dispatch.c:551)
  ==    by 0x4B03B4: dix_main (main.c:277)
  ==    by 0x428941: main (stubmain.c:34)
  ==  Address is 2 bytes after a block of size 28,672 alloc'd
  ==    at 0x4848897: realloc (vg_replace_malloc.c:1804)
  ==    by 0x5E357A: ReadRequestFromClient (io.c:336)
  ==    by 0x4A1FAB: Dispatch (dispatch.c:519)
  ==    by 0x4B03B4: dix_main (main.c:277)
  ==    by 0x428941: main (stubmain.c:34)
  ==

To avoid that issue, add additional bounds checking within the loops by
calling _XkbCheckRequestBounds() and report an error if we are to read
past the client's request.

CVE-2026-34003, ZDI-CAN-28736

This vulnerability was discovered by:
Jan-Niklas Sohn working with TrendAI Zero Day Initiative

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit b85b00dd7b)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2178>
2026-04-14 15:12:24 +02:00
Olivier Fourdan
5328a544ba xkb: Fix out-of-bounds read in CheckModifierMap()
As reported by valgrind:

  == Conditional jump or move depends on uninitialised value(s)
  ==    at 0x547E5B: CheckModifierMap (xkb.c:1972)
  ==    by 0x54A086: _XkbSetMapChecks (xkb.c:2574)
  ==    by 0x54A845: ProcXkbSetMap (xkb.c:2741)
  ==    by 0x556EF4: ProcXkbDispatch (xkb.c:7048)
  ==    by 0x454A8C: Dispatch (dispatch.c:553)
  ==    by 0x462CEB: dix_main (main.c:274)
  ==    by 0x405EA7: main (stubmain.c:34)
  ==  Uninitialised value was created by a heap allocation
  ==    at 0x4840B26: malloc (vg_replace_malloc.c:447)
  ==    by 0x592D5A: AllocateInputBuffer (io.c:981)
  ==    by 0x591F77: InsertFakeRequest (io.c:516)
  ==    by 0x45CA27: NextAvailableClient (dispatch.c:3629)
  ==    by 0x58FA81: AllocNewConnection (connection.c:628)
  ==    by 0x58FC70: EstablishNewConnections (connection.c:692)
  ==    by 0x58FFAA: HandleNotifyFd (connection.c:809)
  ==    by 0x593F42: ospoll_wait (ospoll.c:660)
  ==    by 0x58B9B6: WaitForSomething (WaitFor.c:208)
  ==    by 0x4548AC: Dispatch (dispatch.c:493)
  ==    by 0x462CEB: dix_main (main.c:274)
  ==    by 0x405EA7: main (stubmain.c:34)

The issue is that the loop in CheckModifierMap() reads from wire without
verifying that the data is within the request bounds.

The req->totalModMapKeys value could exceed the actual data provided,
causing reads of uninitialized memory.

To fix that issue, we add a bounds check using _XkbCheckRequestBounds,
but for that, we need to also pass a ClientPtr parameter, which is not
a problem since CheckModifierMap() is a private, static function.

CVE-2026-34002, ZDI-CAN-28737

This vulnerability was discovered by:
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit f056ce1cc9)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2178>
2026-04-14 15:12:24 +02:00
Olivier Fourdan
70aad8867a miext/sync: Fix use-after-free in miSyncTriggerFence()
As reported by valgrind:

  == Invalid read of size 8
  ==    at 0x568C14: miSyncTriggerFence (misync.c:140)
  ==    by 0x540688: ProcSyncTriggerFence (sync.c:1957)
  ==    by 0x540CCC: ProcSyncDispatch (sync.c:2152)
  ==    by 0x4A28C5: Dispatch (dispatch.c:553)
  ==    by 0x4B0B24: dix_main (main.c:274)
  ==    by 0x42915E: main (stubmain.c:34)
  ==  Address 0x17e35488 is 8 bytes inside a block of size 16 free'd
  ==    at 0x4843E43: free (vg_replace_malloc.c:990)
  ==    by 0x53D683: SyncDeleteTriggerFromSyncObject (sync.c:169)
  ==    by 0x53F14D: FreeAwait (sync.c:1208)
  ==    by 0x4DFB06: doFreeResource (resource.c:888)
  ==    by 0x4DFC59: FreeResource (resource.c:918)
  ==    by 0x53E349: SyncAwaitTriggerFired (sync.c:701)
  ==    by 0x568C52: miSyncTriggerFence (misync.c:142)
  ==    by 0x540688: ProcSyncTriggerFence (sync.c:1957)
  ==    by 0x540CCC: ProcSyncDispatch (sync.c:2152)
  ==    by 0x4A28C5: Dispatch (dispatch.c:553)
  ==    by 0x4B0B24: dix_main (main.c:274)
  ==    by 0x42915E: main (stubmain.c:34)
  ==  Block was alloc'd at
  ==    at 0x4840B26: malloc (vg_replace_malloc.c:447)
  ==    by 0x5E50E1: XNFalloc (utils.c:1129)
  ==    by 0x53D772: SyncAddTriggerToSyncObject (sync.c:206)
  ==    by 0x53DCA8: SyncInitTrigger (sync.c:414)
  ==    by 0x5409C7: ProcSyncAwaitFence (sync.c:2089)
  ==    by 0x540D04: ProcSyncDispatch (sync.c:2160)
  ==    by 0x4A28C5: Dispatch (dispatch.c:553)
  ==    by 0x4B0B24: dix_main (main.c:274)
  ==    by 0x42915E: main (stubmain.c:34)

When walking the list of fences to trigger, miSyncTriggerFence() may
call TriggerFence() for the current trigger, which end up calling the
function SyncAwaitTriggerFired().

SyncAwaitTriggerFired() frees the entire await resource, which removes
all triggers from that await - including pNext which may be another
trigger from the same await attached to the same fence.

On the next iteration, ptl = pNext points to freed memory...

To avoid the issue, we need to restart the iteration from the beginning
of the list each time a trigger fires, since the callback can modify the
list.

CVE-2026-34001, ZDI-CAN-28706

This vulnerability was discovered by:
Jan-Niklas Sohn working with TrendAI Zero Day Initiative

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit f19ab94ba9)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2178>
2026-04-14 15:12:24 +02:00
Olivier Fourdan
a48d67f387 xkb: Fix bounds check in _CheckSetGeom()
As reported by valgrind:

  == Conditional jump or move depends on uninitialised value(s)
  ==    at 0x5CBE66: SrvXkbAddGeomKeyAlias (XKBGAlloc.c:585)
  ==    by 0x5AC7D5: _CheckSetGeom (xkb.c:5607)
  ==    by 0x5AC952: _XkbSetGeometry (xkb.c:5643)
  ==    by 0x5ACB58: ProcXkbSetGeometry (xkb.c:5684)
  ==    by 0x5B0DAC: ProcXkbDispatch (xkb.c:7070)
  ==    by 0x4A28C5: Dispatch (dispatch.c:553)
  ==    by 0x4B0B24: dix_main (main.c:274)
  ==    by 0x42915E: main (stubmain.c:34)
  ==  Uninitialised value was created by a heap allocation
  ==    at 0x4840B26: malloc (vg_replace_malloc.c:447)
  ==    by 0x5E13B0: AllocateInputBuffer (io.c:981)
  ==    by 0x5E05CD: InsertFakeRequest (io.c:516)
  ==    by 0x4AA860: NextAvailableClient (dispatch.c:3629)
  ==    by 0x5DE0D7: AllocNewConnection (connection.c:628)
  ==    by 0x5DE2C6: EstablishNewConnections (connection.c:692)
  ==    by 0x5DE600: HandleNotifyFd (connection.c:809)
  ==    by 0x5E2598: ospoll_wait (ospoll.c:660)
  ==    by 0x5DA00C: WaitForSomething (WaitFor.c:208)
  ==    by 0x4A26E5: Dispatch (dispatch.c:493)
  ==    by 0x4B0B24: dix_main (main.c:274)
  ==    by 0x42915E: main (stubmain.c:34)

Each key alias entry contains two key names (the alias and the real key
name), each of size XkbKeyNameLength.

The current bounds check only validates the first name, allowing
XkbAddGeomKeyAlias to potentially read uninitialized memory when
accessing the second name at &wire[XkbKeyNameLength].

To fix this, change the value to check to use 2 * XkbKeyNameLength to
validate the bounds.

CVE-2026-34000, ZDI-CAN-28679

This vulnerability was discovered by:
Jan-Niklas Sohn working with TrendAI Zero Day Initiative

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 81b6a34f90)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2178>
2026-04-14 15:12:24 +02:00
Peter Harris
432cb931cf xkb: fix buffer re-use in _XkbSetCompatMap
If the "compat" buffer has previously been truncated, there will be
unused space in the buffer. The code uses this space, but does not
update the number of valid entries in the buffer.

In the best case, this leads to the new compat entries being ignored. In the
worst case, if there are any "skipped" compat entries, the number of
valid entries will be corrupted, potentially leading to a buffer read
overrun when processing a future request.

Set the number of used "compat" entries when re-using previously
allocated space in the buffer.

CVE-2026-33999, ZDI-CAN-28593

This vulnerability was discovered by:
Jan-Niklas Sohn working with TrendAI Zero Day Initiative

Signed-off-by: Peter Harris <pharris2@rocketsoftware.com>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
(cherry picked from commit b024ae1749)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2178>
2026-04-14 15:12:24 +02:00
Alan Coopersmith
fd9f9f747e os: fix sha1 build error with Nettle 4.0
Nettle 2.6 (released in 2013) split the sha.h header into sha1.h & sha2.h,
but left the sha.h header for compatibility until the recent Nettle 4.0
release finally removed it.

Nettle 4.0 also dropped the length argument from the sha1_digest function.

Closes: #1871
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Pierre Le Marre
5ebf0a9dd7 xkb: Fix serialization of key type without level names
Before this commit the count of key type level names was wrongly set
in `XkbGetNames`: for key type without names, it was set to the level
count, while it should be 0:
- `XkbComputeGetNamesReplySize()` does not account key type without
  level names;
- `XkbSendNames()` does not write any level entry for key types without
  level names.

This causes a mismatch offset while parsing the response and its
processing would ultimately fail.

Fixed by setting the correct level name count: 0 if there is no level
name, else the number of levels.

(cherry picked from commit c49cbc176a)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Pierre Le Marre
bdc7eb8f07 xkb: Fix key type without level names in XkbCopyKeymap
A key type that has no level names is legit. Before this commit,
`XkbCopyKeymap` would make such level inconsistent by setting its
number of levels to 0 while keeping its map entries. It suffices
to clear the names array.

Fixed by copying the level count from the source type.

WARNING: this will trigger an error in `XkbGetNames`, which worked
before this commit only by chance. This is fixed in the next commit.

(cherry picked from commit 12605989af)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Alexander Melnyk
d2f1d74f6c xkb: Fix locked/latched indicator desync across multiple keyboards
When a group indicator (or a latched indicator of any kind) is defined,
e.g.:
  indicator "Scroll Lock" { groups = Group2; }
the logical and physical indicator state may desync across multiple
connected keyboards.

This is caused by XkbPushLockedStateToSlaves only pushing locked_mods to
the slave devices. Pushing locked_group (as well as latched groups/mods)
along with locked_mods resolves the issue.

The issue is not observed with API calls because a different code path
is taken (avoiding XkbPushLockedStateToSlaves altogether).

Signed-off-by: Alexander Melnyk <inboxnumberzero@zoho.com>
(cherry picked from commit 36a7fdd315)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Alan Coopersmith
3797771786 glamor: avoid double free in glamor_make_pixmap_exportable()
Reported by gcc 15.1:

../glamor/glamor_egl.c:320:9:
 warning: double-‘free’ of ‘modifiers’ [CWE-415] [-Wanalyzer-double-free]
[...]
           │  732 |│        free(*modifiers);
           │      |│        ~~~~~~~~~~~~~~~~
           │      |│        |
           │      |└───────>(25) ...to here
           │      |         (26) first ‘free’ here
[...]
    │  320 |         free(modifiers);
    │      |         ~~~~~~~~~~~~~~~
    │      |         |
    │      |         (28) ⚠️  second ‘free’ here; first ‘free’ was at (26)

Fixes: cef12efc1 ("glamor: Implement GetSupportedModifiers")
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 3e9baa20f3)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Alan Coopersmith
b94cdc40b2 glamor: avoid null dereference in glamor_composite_clipped_region()
Reported in #1817:

xwayland-24.1.6/redhat-linux-build/../glamor/glamor_render.c:1577:21:
 warning[-Wanalyzer-null-dereference]: dereference of NULL ‘0’

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 6a4ec30af4)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Alan Coopersmith
0ead657433 glamor: avoid null dereference in glamor_dash_setup()
Reported in #1817:

xwayland-24.1.6/redhat-linux-build/../glamor/glamor_dash.c:152:10:
 warning[-Wanalyzer-null-dereference]: dereference of NULL ‘0’

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit c6522229b8)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Alan Coopersmith
e9d4596386 glamor: handle allocation failures in glamor_largepixmap.c
Reported in #1817:

xwayland-24.1.6/redhat-linux-build/../glamor/glamor_largepixmap.c:130:17:
 warning[-Wanalyzer-possible-null-dereference]:
  dereference of possibly-NULL ‘clipped_regions’

xwayland-24.1.6/redhat-linux-build/../glamor/glamor_largepixmap.c:235:13:
 warning[-Wanalyzer-possible-null-dereference]:
  dereference of possibly-NULL ‘result_regions’

xwayland-24.1.6/redhat-linux-build/../glamor/glamor_largepixmap.c:365:9:
 warning[-Wanalyzer-possible-null-dereference]:
  dereference of possibly-NULL ‘clipped_regions’

xwayland-24.1.6/redhat-linux-build/../glamor/glamor_largepixmap.c:1175:9:
 warning[-Wanalyzer-possible-null-dereference]:
  dereference of possibly-NULL ‘source_pixmap_priv’

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 84cf20e6dd)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Alan Coopersmith
733eab332c glamor: silence false positive in glamor_validate_gc()
We know that if gc->tileIsPixel is false, then gc->tile.pixmap must be
a valid pixmap, but gcc's static analyzer doesn't and needs to be told.

Silences false positive reported in #1817:

xwayland-24.1.6/redhat-linux-build/../glamor/glamor_core.c:205:19:
 warning[-Wanalyzer-null-dereference]: dereference of NULL ‘0’

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit a79bdc495e)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Alan Coopersmith
b00201506a glamor: handle allocation failure in glamor_create_pixmap()
Reported by gcc 15.1:

../glamor/glamor.c: In function ‘glamor_create_pixmap’:
../glamor/glamor.c:233:23: warning: potential null pointer dereference
 [-Wnull-dereference]
  233 |     pixmap_priv->type = GLAMOR_TEXTURE_ONLY;
      |     ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
../glamor/glamor.c:228:26: warning: potential null pointer dereference
 [-Wnull-dereference]
  228 |     pixmap_priv->is_cbcr = (GLAMOR_CREATE_FORMAT_CBCR & usage) == GLAMOR_CREATE_FORMAT_CBCR;

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit cc647f2367)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Alan Coopersmith
91af36ed50 glamor: handle potential NULL return from GetPictureScreenIfSet()
Unlike GetPictureScreen(), GetPictureScreenIfSet() checks if the
private key is registered, and returns NULL if it is not.

Reported in #1817:
xwayland-24.1.6/redhat-linux-build/../glamor/glamor.c:926:5:
 warning[-Wanalyzer-null-dereference]: dereference of NULL ‘ps’

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 69b48423bd)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Alan Coopersmith
13cb37f179 meson: don't build xselinux if xace is disabled
xselinux requires xace to build

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 7b15321b3b)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Alan Coopersmith
7a6c6bf9ee dix: Fix builds with meson -Dxace=false -Dwerror=true
CI meson-disable-options builds were failing with:
../dix/events.c: In function ‘CoreEnterLeaveEvent’:
../dix/events.c:4723:19: error: unused variable ‘client’
 [-Werror=unused-variable]
 4723 |         ClientPtr client = grab ? rClient(grab) : wClient(pWin);
      |                   ^~~~~~
../dix/events.c: In function ‘CoreFocusEvent’:
../dix/events.c:4834:19: error: unused variable ‘client’
 [-Werror=unused-variable]
 4834 |         ClientPtr client = wClient(pWin);
      |                   ^~~~~~

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 6611caf828)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Alan Coopersmith
d6d9beada9 xf86bigfont: fix -Wimplicit-function-declaration error
Build breaks with gcc 14 & later when xf86bigfont is enabled:

../Xext/xf86bigfont.c: In function ‘XFree86BigfontExtensionInit’:
../Xext/xf86bigfont.c:709:28: error: implicit declaration of function
 ‘xfont2_allocate_font_private_index’;
 did you mean ‘AllocateFontPrivateIndex’? [-Wimplicit-function-declaration]
  709 |         FontShmdescIndex = xfont2_allocate_font_private_index();
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                            AllocateFontPrivateIndex

Fixes: 05a793f5b ("dix: Switch to the libXfont2 API (v2)")
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 0617f6075b)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Twaik Yont
032715f273 os: use close-on-exec for X server socket to prevent fd leaks
In most typical Linux X servers (like Xvfb, Xephyr, or Xwayland), no child process outlives the server, so this issue rarely arises. However, in embedded X servers (based on Xvfb or Kdrive) or in custom Xorg modules, the server might launch a long-running command with regular fork+exec calls. If the X server crashes or exits while that command is still running (for example, it spawns a tombstone generator or any process that hangs or turns to zombie), the file descriptor associated with the abstract socket can remain open in the child process. This leads to the kernel refusing to allow another X server to bind the same socket until the child process terminates (because there is no explicit way to unlink abstract socket, unlike Unix socket). By marking the file descriptor as close-on-exec, we ensure it is automatically closed in child processes, preserving the ability of a new X server process to bind the socket immediately.

Signed-off-by: Twaik Yont <9674930+twaik@users.noreply.github.com>
(cherry picked from commit 5568b0f83f)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Alan Coopersmith
33eee35e0c os: make FormatInt64() handle LONG_MIN correctly
When compiling with gcc 15.2.0 using -O3 -m64 on Solaris SPARC & x64,
we'd get a test failure of:

Assertion failed: strcmp(logmsg, expected) == 0,
 file ../test/signal-logging.c, line 339, function logging_format

because 'num *= 1' produced a value that was out of the range of the
int64_t it was being stored in.  (Compiling with -O2 worked fine with
the same compiler/configuration/platform though.)

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 7f68b58865)
(cherry picked from commit 3eac9393d7)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Alan Coopersmith
447fec7d5e os: include <assert.h> in ospoll.c
Fixes build failure in mingw-cross-build:

../os/ospoll.c: In function ‘ospoll_destroy’:
../os/ospoll.c:266:9: error: implicit declaration of function ‘assert’
 [-Werror=implicit-function-declaration]
  266 |         assert (ospoll->num == 0);
      |         ^~~~~~
../os/ospoll.c:59:1: note: ‘assert’ is defined in header ‘<assert.h>’;
 did you forget to ‘#include <assert.h>’?
   58 | #include "xserver_poll.h"
  +++ |+#include <assert.h>
   59 | #define POLL            1
../os/ospoll.c:266:9: warning: nested extern declaration of ‘assert’
 [-Wnested-externs]
  266 |         assert (ospoll->num == 0);
      |         ^~~~~~

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 7f8570bfa1)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Benjamin Valentin
cc3a8739eb xf86: check return value of XF86_CRTC_CONFIG_PTR in xf86CompatOutput()
If privates[xf86CrtcConfigPrivateIndex].ptr is NULL, this will cause
a segfault.

Possible fix for !1241

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
(cherry picked from commit 907c501926)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
Matthieu Herrb
fe14f01089 Better fix for xf86CompatOut() when there are no privates
XF86_CRTC_CONFIG_PTR() will derefence privates[-1] in this case.

Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
(cherry picked from commit 75d7061288)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
hongao
ce300ed2bc randr: clear primary screen's primaryOutput when the output is deleted
This fix use after free when a pluggable gpu screen (such as displaylink)
was set as primary screen and unpluged.

gdb backtrace:
 #0 OssigHandler (signo=11, sip=0x7fff2e0a50f0, unused=0x7fff2e0a4fc0) at ../../../../os/osinit.c:138
 #1 <signal handler called>
 #2 rrGetscreenResources (client=0x3195160, query=0) at ../../../../randr/rrscreen.c:577
 #3 0x0000000000562bae in ProcRRGetscreenResourcesCurrent (client=0x3195160) at ../../../../randr/rrscreen.c:652
 #4 OxOOOOB0000054de63 in ProcRRDispatch (client=0x3195160) at ../../../../randr/randr.c:717
 #5 0x00000000004322c6 in Dispatch () at ../../../../dix/dispatch.c:485
 #6 0x0900900990443139 in dix_main (argc=12, argv=0x7fff2e0a5f78, envp=0x7fff2e0a5fe0) at ../../../../dix/main.c:276
 #7 0X0000000000421d9a in main (argc=12, argv=0x7fff2e0a5f78, envp=0x7fff2e0a5fe0) at ../../../../dix/stubmain.c:34

Signed-off-by: hongao <hongao@uniontech.com>
(cherry picked from commit 1443fd34ea)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:39:59 +00:00
quantenzitrone
dd924b160c COPYING: add author to HPND-sell-MIT-disclaimer-xserver
the license notice comes from these files:
- dix/registry.c
- Xext/xselinuxint.h
- Xext/xselinux_label.c
- Xext/xselinux_hooks.c
- Xext/xselinux_ext.c
- Xext/xselinux.h
- Xext/xacestr.h
- Xext/xace.h
- Xext/xace.c

while this is not like the standard `Copyright (C)` lines I think it
still belongs to the license, even if just to make it more clearly
separate from the MIT license above

(cherry picked from commit fff0023339)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:39:59 +00:00
quantenzitrone
3069f64d69 COPYING: add missing paragraph to SGI-B-2.0
all files that this license applies to include the last paragraph:
- glx/xfont.c
- glx/unpack.h
- glx/singlesize.h
- glx/singlesize.c
- glx/singlepixswap.c
- glx/singlepix.c
- glx/single2swap.c
- glx/single2.c
- glx/rensize.c
- glx/renderpixswap.c
- glx/renderpix.c
- glx/render2swap.c
- glx/render2.c
- glx/glxutil.h
- glx/glxdrawable.h
- glx/glxserver.h
- glx/glxcontext.h
- glx/glxscreens.h
- glx/glxscreens.c
- glx/glxcmdsswap.c
- glx/glxext.h
- glx/glxcmds.c
- glx/glxext.c

the paragraph was likely accidentally missed when the license changed
from SGI-B-1.0 to SGI-B-2.0 in ed9aecf851

(cherry picked from commit 6105e5b133)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:39:59 +00:00
Mikhail Dmitrichenko
9ee6ae7292 dix: avoid null ptr deref at doListFontsAndAliases
In the `doListFontsAndAliases` function in dixfonts.c, when a font alias
is encountered (`err == FontNameAlias`) as a result of
`list_next_font_or_alias` call, the code allocates memory for
`resolved` variable (`resolvedlen + 1` bytes) for storing target font
name. In this case, if the `malloc(resolvedlen + 1)` call fails,
`resolved` remains NULL.

Later, when check (`else if (err == FontNameAlias)`) is TRUE, the code
uses `memcpy` to copy nullable `resolved` into `tmp_pattern` without
checking if `resolved` is NULL, so there is a potential null ptr
dereference.

This commit replaces `malloc` with `XNFalloc` for allocating memory for
`resolved`. `XNFalloc` will internally check result of `malloc` and stop
program execution if allocation was failed, preventing potential NULL
dereferencing.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
(cherry picked from commit 0237462d32)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:39:59 +00:00
Mikhail Dmitrichenko
123f50acb3 render: fix multiple mem leaks on err paths
Free nested allocations when initialization fails.
Several code paths returned early on error without releasing
memory owned by embedded structures, leading to leaks.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
(cherry picked from commit 809402414e)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:39:59 +00:00
Mikhail Dmitrichenko
ff10e6d044 os: avoid closing null fd at Fopen
In `Fopen` function variable `iop` may store NULL as a result of `fopen`
call. In this case, if later privileges couldn't be restored (`seteuid`
call fails), further `fclose(iop)` call will cause runtime error.

This commit adds check `iop` for NULL before calling `fclose` to prevent
potential NULL pointer dereference.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
(cherry picked from commit f83807647e)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:39:59 +00:00
Alan Coopersmith
c014619640 dix: set errorValue correctly when XID lookup fails in ChangeGCXIDs()
dixLookupResourceByType always overwrites the pointer passed in as the
first arg, so we shouldn't use the union it's in after that to get the
requested XID value to put in the errorValue.

Closes: #1857
Fixes: 2d7eb4a19 ("Pre-validate ChangeGC XIDs.")
Reported-by: Mouse <mouse@Rodents-Montreal.ORG>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit ac42c39145)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:39:59 +00:00
Takashi Yano
ec4e918d85 Fix mach64 driver crash
Due to lack of iopl(3), mach64 driver crashes when ior(BUS_CNTL) is
called. Since BUS_CNTL is out of the range 0x0000-0x03ff, ioperm(0,
1024, 1) is not sufficient and the ior() causes access violation.
This patch reintroduce iopl(3) call in the function hwEnableIO().

Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1110521
Fixes: a0f738a673 ("Fixed ioperm calls in hwEnableIO")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
(cherry picked from commit 3b39aebf98)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:39:59 +00:00
Alan Coopersmith
3b92ab189b xfree86: Fix builds with gcc -Wpedantic
../hw/xfree86/loader/loadmod.c:85:33: warning: ISO C forbids empty
 initializer braces before C23 [-Wpedantic]
   85 | static int ModuleDuplicated[] = { };
      |                                 ^
../hw/xfree86/loader/loadmod.c:85:12: error: zero or negative size array
 ‘ModuleDuplicated’
   85 | static int ModuleDuplicated[] = { };
      |            ^~~~~~~~~~~~~~~~

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit d03c84b57f)
(cherry picked from commit 3e0f37c95c)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:39:59 +00:00
Jeremy Huddleston Sequoia
65f4ce96cc xquartz: Bump copyrights in Info.plist to 2026
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
(cherry picked from commit fbff1312ce)
2026-03-25 23:47:59 -07:00
Jeremy Huddleston Sequoia
ef781045ee rootless: Protect alpha channel for Render operations
The Render extension operates on PictFormats rather than GC, so it
bypasses the rootless layer's GC-based alpha protection
(ROOTLESS_PROTECT_ALPHA).  Depth-24 windows use PICT_x8r8g8b8 where
the 'x' tells pixman the high byte is padding it may freely zero.
The macOS compositor needs this byte to be 0xFF (opaque).

Before each Render operation that targets a rootless window,
temporarily upgrade the destination Picture's format from
PICT_x8r8g8b8 to PICT_a8r8g8b8.  This tells pixman that the alpha
channel is significant and must not be optimized away.  The format
is restored after the operation completes.

This parallels how ROOTLESS_PROTECT_ALPHA handles GC operations (by
masking alpha out of the planemask) and how ROOTLESS_SAFEALPHA
handles PaintWindow (by forcing alpha in solid fills).  The
save/restore approach is analogous to rootlessGC.c's GC_SAVE /
GC_RESTORE pattern.

Fixes [2/2]: https://github.com/XQuartz/XQuartz/issues/31

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
(cherry picked from commit d2e83a266c)
2026-03-24 20:59:03 -07:00
Jeremy Huddleston Sequoia
d7279b8e4f rootless: Add Trapezoids, Triangles, and CompositeRects wrapping
The Render extension's Trapezoids and Triangles operations
(fbTrapezoids, fbTriangles) render directly via pixman through
fbShapes without going through ps->Composite, so RootlessComposite
never fires for these operations.  This means RootlessStartDrawing
is not called and the macOS compositor is not notified of changed
pixels.

Add RootlessTrapezoids and RootlessTriangles wrappers following the
same pattern as RootlessComposite: call RootlessStartDrawing before
the operation, then compute the bounding box via miTrapezoidBounds or
miTriangleBounds and call RootlessDamageBox after.  The default
miTriStrip and miTriFan implementations decompose their input into
triangles and dispatch through ps->Triangles, so the RootlessTriangles
wrapper covers TriStrip and TriFan as well.

Also add a RootlessCompositeRects wrapper as defense-in-depth.  The
current miCompositeRects implementation already has partial rootless
coverage: PictOpSrc/PictOpClear go through the GC layer, and other
ops route through CompositePicture -> RootlessComposite.  Wrapping at
the PictureScreen level ensures robustness regardless of the underlying
implementation.

Fixes [1/2]: https://github.com/XQuartz/XQuartz/issues/31

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
(cherry picked from commit 40b762cf6d)
2026-03-24 20:59:02 -07:00
Jeremy Huddleston Sequoia
09eb9aa351 rootless: Fix Glyphs damage bounding box to correctly compute union
RootlessGlyphs used max() for box.x1 and box.y1 when accumulating the
bounding box across glyphs in a list.  Computing the union of bounding
boxes requires min() for the lower coordinate corner and max for the
higher coordinate corner.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
(cherry picked from commit e8936920ee)
2026-03-24 20:59:01 -07:00
Alan Coopersmith
d5aefa60ce Makefile.am: add SECURITY.md to EXTRA_DIST
Include it in the tarballs generated by automake

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2106>
2025-11-30 17:21:49 +00:00
Alan Coopersmith
d7c83b8881 Create a SECURITY.md file
Provide information on where to report or learn of security bugs,
and what we do or do not consider to be a security bug.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit a5047d4a65)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2106>
2025-11-30 17:21:49 +00:00
Olivier Fourdan
312a25c65c xserver 21.1.21
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2108>
2025-11-24 18:03:35 +01:00
Olivier Fourdan
75d6e5d20b Revert "glamor: add glvnd_vendor private"
This reverts commit a6145198bc.

We no longer need to store the glvnd vendor, so we can also drop that
change.

See-also: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1848
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2104>
2025-11-20 14:13:21 +01:00
Olivier Fourdan
399177dc8c Revert "glamor: Lift the GLX EGL backend from Xwayland"
This reverts commit ed1ec13502.
This reverts commit 3837159a3f.

We no longer use GLX provider for glamor, so we can remove that code.

See-also: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1848
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2104>
2025-11-20 14:13:21 +01:00
Olivier Fourdan
d9ea493a60 Revert "xorg: initialize glamor provider"
This reverts commit 0a1ee643b2.

This is causing a number of regressions on existing setups:

 * Reverse PRIME with the NVIDIA proprietary driver, where software
   rendering is used instead of the NVIDIA GLX library with hardware
   acceleration
 * Performance issues with AMDGPU
 * Rendering with 10-bit output with AMDGPU

Revert the change that is causing these regressions in the stable branch.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1848
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2104>
2025-11-20 14:13:21 +01:00
Olivier Fourdan
ff37280fd9 Revert "glamor_egl: add support of GlxVendorLibrary option"
This reverts commit 062d399770.

There is an issue with this code in GLAMOR EGL and using this option in
the "xorg.conf" would lead to a segmentation fault in the Xserver.

Instead of fixing the code for that option in GLAMOR EGL, let's revert
the commit in the stable branch, since we are to revert support for
glamor GLX, this options will no longer be needed.

See-also: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1848
See-also: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2096
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2104>
2025-11-20 14:13:21 +01:00
Olivier Fourdan
0b079e12b2 Revert "glamor: reject configs using unsupported rgbBits size"
This reverts commit b89a563882.

This is a fix for a code path that we are about to remove with the next
few reverts, so start by reverting this change.

See-also: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1848
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2104>
2025-11-20 14:13:21 +01:00
Olivier Fourdan
065f02d946 xserver 21.1.20
Quick release to fix the missing files in 21.1.19.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2090>
2025-10-28 17:40:09 +01:00
Olivier Fourdan
3362fec06a tests: Add missing files to Makefile build
The script comes from a backport where only meson is used and therefore
the new files were omitted from the Makefile.

As a result, these files are not included in the released tar file and
the build fails.

Fixes: 95b899118 - meson: add glamor gles2 tests
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2089>
2025-10-28 17:00:57 +01:00
Olivier Fourdan
a10c9018ff xserver 21.1.19
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2087>
2025-10-28 14:15:35 +01:00