mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-06-07 02:58:22 +02:00
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 Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2228>
This commit is contained in:
parent
543e108516
commit
867b59b33b
1 changed files with 5 additions and 0 deletions
|
|
@ -1621,6 +1621,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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue