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

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