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

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