Blame SOURCES/0003-Xi-avoid-integer-truncation-in-length-check-of-ProcX.patch

290b8e
From f9c435822c852659e3926502829f1b13ce6efc37 Mon Sep 17 00:00:00 2001
290b8e
From: Peter Hutterer <peter.hutterer@who-t.net>
290b8e
Date: Tue, 29 Nov 2022 13:26:57 +1000
290b8e
Subject: [PATCH xserver 3/7] Xi: avoid integer truncation in length check of
290b8e
 ProcXIChangeProperty
290b8e
290b8e
This fixes an OOB read and the resulting information disclosure.
290b8e
290b8e
Length calculation for the request was clipped to a 32-bit integer. With
290b8e
the correct stuff->num_items value the expected request size was
290b8e
truncated, passing the REQUEST_FIXED_SIZE check.
290b8e
290b8e
The server then proceeded with reading at least stuff->num_items bytes
290b8e
(depending on stuff->format) from the request and stuffing whatever it
290b8e
finds into the property. In the process it would also allocate at least
290b8e
stuff->num_items bytes, i.e. 4GB.
290b8e
290b8e
The same bug exists in ProcChangeProperty and ProcXChangeDeviceProperty,
290b8e
so let's fix that too.
290b8e
290b8e
CVE-2022-46344, ZDI-CAN 19405
290b8e
290b8e
This vulnerability was discovered by:
290b8e
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
290b8e
290b8e
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
290b8e
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
290b8e
---
290b8e
 Xi/xiproperty.c | 4 ++--
290b8e
 dix/property.c  | 3 ++-
290b8e
 2 files changed, 4 insertions(+), 3 deletions(-)
290b8e
290b8e
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
290b8e
index 68c362c628..066ba21fba 100644
290b8e
--- a/Xi/xiproperty.c
290b8e
+++ b/Xi/xiproperty.c
290b8e
@@ -890,7 +890,7 @@ ProcXChangeDeviceProperty(ClientPtr client)
290b8e
     REQUEST(xChangeDevicePropertyReq);
290b8e
     DeviceIntPtr dev;
290b8e
     unsigned long len;
290b8e
-    int totalSize;
290b8e
+    uint64_t totalSize;
290b8e
     int rc;
290b8e
290b8e
     REQUEST_AT_LEAST_SIZE(xChangeDevicePropertyReq);
290b8e
@@ -1130,7 +1130,7 @@ ProcXIChangeProperty(ClientPtr client)
290b8e
 {
290b8e
     int rc;
290b8e
     DeviceIntPtr dev;
290b8e
-    int totalSize;
290b8e
+    uint64_t totalSize;
290b8e
     unsigned long len;
290b8e
290b8e
     REQUEST(xXIChangePropertyReq);
290b8e
diff --git a/dix/property.c b/dix/property.c
290b8e
index 94ef5a0ec0..acce94b2c6 100644
290b8e
--- a/dix/property.c
290b8e
+++ b/dix/property.c
290b8e
@@ -205,7 +205,8 @@ ProcChangeProperty(ClientPtr client)
290b8e
     WindowPtr pWin;
290b8e
     char format, mode;
290b8e
     unsigned long len;
290b8e
-    int sizeInBytes, totalSize, err;
290b8e
+    int sizeInBytes, err;
290b8e
+    uint64_t totalSize;
290b8e
290b8e
     REQUEST(xChangePropertyReq);
290b8e
290b8e
--
290b8e
2.38.1