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

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