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

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