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)
This commit is contained in:
Peter Hutterer 2026-08-26 17:16:49 +10:00 • committed by Enrico Weigelt
commit b8668c00f6

View file

@ -2195,6 +2195,9 @@ __glXDisp_RenderLarge(__GLXclientState * cl, GLbyte * pc)
return BadLength;
}
if (dataBytes > cmdlen)
return BadLength;
/*
** Make enough space in the buffer, then copy the entire request.
*/