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

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