Blame SOURCES/xorg-CVE-2023-6816.patch

2d42f4
From 77e294797db17845808462b588d4e7a2130196bc Mon Sep 17 00:00:00 2001
2d42f4
From: Peter Hutterer <peter.hutterer@who-t.net>
2d42f4
Date: Thu, 14 Dec 2023 11:29:49 +1000
2d42f4
Subject: [PATCH xserver] dix: allocate enough space for logical button maps
2d42f4
2d42f4
Both DeviceFocusEvent and the XIQueryPointer reply contain a bit for
2d42f4
each logical button currently down. Since buttons can be arbitrarily mapped
2d42f4
to anything up to 255 make sure we have enough bits for the maximum mapping.
2d42f4
2d42f4
CVE-2023-6816, ZDI-CAN-22664, ZDI-CAN-22665
2d42f4
2d42f4
This vulnerability was discovered by:
2d42f4
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
2d42f4
---
2d42f4
 Xi/xiquerypointer.c | 3 +--
2d42f4
 dix/enterleave.c    | 5 +++--
2d42f4
 2 files changed, 4 insertions(+), 4 deletions(-)
2d42f4
2d42f4
diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
2d42f4
index 5b77b1a444..2b05ac5f39 100644
2d42f4
--- a/Xi/xiquerypointer.c
2d42f4
+++ b/Xi/xiquerypointer.c
2d42f4
@@ -149,8 +149,7 @@ ProcXIQueryPointer(ClientPtr client)
2d42f4
     if (pDev->button) {
2d42f4
         int i;
2d42f4
 
2d42f4
-        rep.buttons_len =
2d42f4
-            bytes_to_int32(bits_to_bytes(pDev->button->numButtons));
2d42f4
+        rep.buttons_len = bytes_to_int32(bits_to_bytes(256)); /* button map up to 255 */
2d42f4
         rep.length += rep.buttons_len;
2d42f4
         buttons = calloc(rep.buttons_len, 4);
2d42f4
         if (!buttons)
2d42f4
diff --git a/dix/enterleave.c b/dix/enterleave.c
2d42f4
index 867ec74363..ded8679d76 100644
2d42f4
--- a/dix/enterleave.c
2d42f4
+++ b/dix/enterleave.c
2d42f4
@@ -784,8 +784,9 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
2d42f4
 
2d42f4
     mouse = IsFloating(dev) ? dev : GetMaster(dev, MASTER_POINTER);
2d42f4
 
2d42f4
-    /* XI 2 event */
2d42f4
-    btlen = (mouse->button) ? bits_to_bytes(mouse->button->numButtons) : 0;
2d42f4
+    /* XI 2 event contains the logical button map - maps are CARD8
2d42f4
+     * so we need 256 bits for the possibly maximum mapping */
2d42f4
+    btlen = (mouse->button) ? bits_to_bytes(256) : 0;
2d42f4
     btlen = bytes_to_int32(btlen);
2d42f4
     len = sizeof(xXIFocusInEvent) + btlen * 4;
2d42f4
 
2d42f4
-- 
2d42f4
2.43.0
2d42f4