Blame SOURCES/0001-dix-allocate-enough-space-for-logical-button-maps.patch

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