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

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