xorg-x11-server-Xwayland/0004-xkb-clamp-nMaps-to-mapWidths-buffer-size-in-CheckKey.patch
Olivier Fourdan 3b045669f9 CVE fixes
CVE-2026-50256 (ZDI-CAN-30136)
CVE-2026-50263 (ZDI-CAN-30168)
CVE-2026-50262 (ZDI-CAN-30165)
CVE-2026-50259 (ZDI-CAN-30161)
CVE-2026-50258 (ZDI-CAN-30160)
CVE-2026-50261 (ZDI-CAN-30164)
CVE-2026-50257 (ZDI-CAN-30159)
CVE-2026-50260 (ZDI-CAN-30163)

Resolves: https://redhat.atlassian.net/browse/RHEL-182444
2026-06-09 16:53:06 +02:00

53 lines
2 KiB
Diff

From cb0e17cc7890d41bfee39f5bfcfeec521b0d513d Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Mon, 20 Apr 2026 11:18:13 +1000
Subject: [PATCH xserver 4/7] xkb: clamp nMaps to mapWidths buffer size in
CheckKeyTypes
CheckKeyTypes computes nMaps = firstType + nTypes from client-controlled
request fields when XkbSetMapResizeTypes is set. This value is used to
index mapWidths[], a stack-allocated CARD8 array of XkbMaxLegalKeyCode + 1
(256) elements. No upper bound is enforced on nMaps.
An attacker can first send SetMap(firstType=0, nTypes=255, ResizeTypes) to
set the server's num_types to 255, then send SetMap(firstType=255,
nTypes=10, ResizeTypes). The firstType > num_types check passes because
255 > 255 is false (the check uses > rather than >=). nMaps is then
computed as 265, and the loop writes mapWidths[255..264], overflowing 9
bytes past the stack buffer into adjacent stack variables (symsPerKey[]).
Fix by rejecting requests where firstType + nTypes would exceed the
mapWidths buffer size (XkbMaxLegalKeyCode + 1).
This vulnerability was discovered by:
Anonymous working with TrendAI Zero Day Initiative
ZDI-CAN-30161
Assisted-by: Claude:claude-opus-4-6
(cherry picked from commit 867b59b33bee669cb412f1314e47c52eacf6e00b)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2230>
---
xkb/xkb.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/xkb/xkb.c b/xkb/xkb.c
index b5d601dcb..ae6a4c09e 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -1616,6 +1616,11 @@ CheckKeyTypes(ClientPtr client,
*nMapsRtrn = _XkbErrCode4(0x02, req->firstType, req->nTypes, 4);
return 0;
}
+ if (nMaps > XkbMaxLegalKeyCode + 1) {
+ *nMapsRtrn = _XkbErrCode4(0x02, req->firstType, req->nTypes,
+ XkbMaxLegalKeyCode + 1);
+ return 0;
+ }
}
else if (req->present & XkbKeyTypesMask) {
nMaps = xkb->map->num_types;
--
2.54.0