From 26c1df93d9b0ec0dcd8b366dbc4d7c170600c13c Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Mar 28 2023 12:33:33 +0000 Subject: import xorg-x11-server-1.20.11-17.el9 --- diff --git a/SOURCES/0001-Xi-fix-potential-use-after-free-in-DeepCopyPointerCl.patch b/SOURCES/0001-Xi-fix-potential-use-after-free-in-DeepCopyPointerCl.patch new file mode 100644 index 0000000..b64bb1f --- /dev/null +++ b/SOURCES/0001-Xi-fix-potential-use-after-free-in-DeepCopyPointerCl.patch @@ -0,0 +1,36 @@ +From 9ca7d3f61a88ae6cf47fdf139b6215d745db976b Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Wed, 25 Jan 2023 11:41:40 +1000 +Subject: [PATCH xserver] Xi: fix potential use-after-free in + DeepCopyPointerClasses + +CVE-2023-0494, ZDI-CAN-19596 + +This vulnerability was discovered by: +Jan-Niklas Sohn working with Trend Micro Zero Day Initiative + +Signed-off-by: Peter Hutterer +(cherry picked from commit 0ba6d8c37071131a49790243cdac55392ecf71ec) +--- + Xi/exevents.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/Xi/exevents.c b/Xi/exevents.c +index 217baa9561..dcd4efb3bc 100644 +--- a/Xi/exevents.c ++++ b/Xi/exevents.c +@@ -619,8 +619,10 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) + memcpy(to->button->xkb_acts, from->button->xkb_acts, + sizeof(XkbAction)); + } +- else ++ else { + free(to->button->xkb_acts); ++ to->button->xkb_acts = NULL; ++ } + + memcpy(to->button->labels, from->button->labels, + from->button->numButtons * sizeof(Atom)); +-- +2.39.0 + diff --git a/SOURCES/0001-Xtest-disallow-GenericEvents-in-XTestSwapFakeInput.patch b/SOURCES/0001-Xtest-disallow-GenericEvents-in-XTestSwapFakeInput.patch new file mode 100644 index 0000000..7e671d1 --- /dev/null +++ b/SOURCES/0001-Xtest-disallow-GenericEvents-in-XTestSwapFakeInput.patch @@ -0,0 +1,52 @@ +From b320ca0ffe4c0c872eeb3a93d9bde21f765c7c63 Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Tue, 29 Nov 2022 12:55:45 +1000 +Subject: [PATCH xserver 1/7] Xtest: disallow GenericEvents in + XTestSwapFakeInput + +XTestSwapFakeInput assumes all events in this request are +sizeof(xEvent) and iterates through these in 32-byte increments. +However, a GenericEvent may be of arbitrary length longer than 32 bytes, +so any GenericEvent in this list would result in subsequent events to be +misparsed. + +Additional, the swapped event is written into a stack-allocated struct +xEvent (size 32 bytes). For any GenericEvent longer than 32 bytes, +swapping the event may thus smash the stack like an avocado on toast. + +Catch this case early and return BadValue for any GenericEvent. +Which is what would happen in unswapped setups anyway since XTest +doesn't support GenericEvent. + +CVE-2022-46340, ZDI-CAN 19265 + +This vulnerability was discovered by: +Jan-Niklas Sohn working with Trend Micro Zero Day Initiative + +Signed-off-by: Peter Hutterer +Acked-by: Olivier Fourdan +--- + Xext/xtest.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/Xext/xtest.c b/Xext/xtest.c +index bf27eb590b..2985a4ce6e 100644 +--- a/Xext/xtest.c ++++ b/Xext/xtest.c +@@ -502,10 +502,11 @@ XTestSwapFakeInput(ClientPtr client, xReq * req) + + nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent); + for (ev = (xEvent *) &req[1]; --nev >= 0; ev++) { ++ int evtype = ev->u.u.type & 0x177; + /* Swap event */ +- proc = EventSwapVector[ev->u.u.type & 0177]; ++ proc = EventSwapVector[evtype]; + /* no swapping proc; invalid event type? */ +- if (!proc || proc == NotImplemented) { ++ if (!proc || proc == NotImplemented || evtype == GenericEvent) { + client->errorValue = ev->u.u.type; + return BadValue; + } +-- +2.38.1 + diff --git a/SOURCES/0001-configure.ac-search-for-the-fontrootdir-ourselves.patch b/SOURCES/0001-configure.ac-search-for-the-fontrootdir-ourselves.patch new file mode 100644 index 0000000..3e29358 --- /dev/null +++ b/SOURCES/0001-configure.ac-search-for-the-fontrootdir-ourselves.patch @@ -0,0 +1,72 @@ +From e67e988730346c63d2f0cdf2531ed36b0c7ad5a6 Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Wed, 23 Nov 2022 14:50:29 +1000 +Subject: [PATCH xserver] configure.ac: search for the fontrootdir ourselves + +This replaces the use of font-utils' .m4 macro set with a copy of the +only one we actually want: the bit for the fontrootpath. + +We don't need configure options for every single subfont directory, so +let's hardcode those in the default font path. Like meson does upstream +too. + +With this patch we no longer require the font-utils dependency. + +Signed-off-by: Peter Hutterer +--- + configure.ac | 28 +++++++++++++++++----------- + 1 file changed, 17 insertions(+), 11 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 0909cc5b4d..2349320888 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -49,9 +49,6 @@ XORG_WITH_XSLTPROC + XORG_ENABLE_UNIT_TESTS + XORG_LD_WRAP([optional]) + +-m4_ifndef([XORG_FONT_MACROS_VERSION], [m4_fatal([must install font-util 1.1 or later before running autoconf/autogen])]) +-XORG_FONT_MACROS_VERSION(1.1) +- + dnl this gets generated by autoheader, and thus contains all the defines. we + dnl don't ever actually use it, internally. + AC_CONFIG_HEADERS(include/do-not-use-config.h) +@@ -450,18 +447,27 @@ AC_MSG_RESULT([$FALLBACK_INPUT_DRIVER]) + AC_DEFINE_UNQUOTED(FALLBACK_INPUT_DRIVER, ["$FALLBACK_INPUT_DRIVER"], [ Fallback input driver ]) + + dnl Determine font path +-XORG_FONTROOTDIR +-XORG_FONTSUBDIR(FONTMISCDIR, fontmiscdir, misc) +-XORG_FONTSUBDIR(FONTOTFDIR, fontotfdir, OTF) +-XORG_FONTSUBDIR(FONTTTFDIR, fontttfdir, TTF) +-XORG_FONTSUBDIR(FONTTYPE1DIR, fonttype1dir, Type1) +-XORG_FONTSUBDIR(FONT75DPIDIR, font75dpidir, 75dpi) +-XORG_FONTSUBDIR(FONT100DPIDIR, font100dpidir, 100dpi) ++dnl This is a copy of XORG_FONTROOTDIR from font-utils so we can drop the dependency ++AC_MSG_CHECKING([for root directory for font files]) ++AC_ARG_WITH(fontrootdir, ++ AS_HELP_STRING([--with-fontrootdir=DIR], ++ [Path to root directory for font files]), ++ [FONTROOTDIR="$withval"]) ++# if --with-fontrootdir not specified... ++if test "x${FONTROOTDIR}" = "x"; then ++ FONTROOTDIR=`$PKG_CONFIG --variable=fontrootdir fontutil` ++fi ++# ...and if pkg-config didn't find fontdir in fontutil.pc... ++if test "x${FONTROOTDIR}" = "x"; then ++ FONTROOTDIR="${datadir}/fonts/X11" ++fi ++AC_SUBST(FONTROOTDIR) ++AC_MSG_RESULT([${FONTROOTDIR}]) + + dnl Uses --with-default-font-path if set, otherwise uses standard + dnl subdirectories of FONTROOTDIR. Some distros set the default font path to + dnl "catalogue:/etc/X11/fontpath.d,built-ins" +-DEFAULT_FONT_PATH="${FONTMISCDIR}/,${FONTTTFDIR}/,${FONTOTFDIR}/,${FONTTYPE1DIR}/,${FONT100DPIDIR}/,${FONT75DPIDIR}/" ++DEFAULT_FONT_PATH="${FONTROOTDIR}/misc,${FONTROOTDIR}/OTF,${FONTROOTDIR}/TTF,${FONTROOTDIR}/Type1,${FONTROOTDIR}/75dpi,${FONTROOTDIR}/100dpi" + case $host_os in + darwin*) DEFAULT_FONT_PATH="${DEFAULT_FONT_PATH},/Library/Fonts,/System/Library/Fonts" ;; + esac +-- +2.38.1 + diff --git a/SOURCES/0001-xkb-fix-some-possible-memleaks-in-XkbGetKbdByName.patch b/SOURCES/0001-xkb-fix-some-possible-memleaks-in-XkbGetKbdByName.patch new file mode 100644 index 0000000..6e5ebb5 --- /dev/null +++ b/SOURCES/0001-xkb-fix-some-possible-memleaks-in-XkbGetKbdByName.patch @@ -0,0 +1,59 @@ +From 18f91b950e22c2a342a4fbc55e9ddf7534a707d2 Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Wed, 13 Jul 2022 11:23:09 +1000 +Subject: [PATCH xserver] xkb: fix some possible memleaks in XkbGetKbdByName + +GetComponentByName returns an allocated string, so let's free that if we +fail somewhere. + +Signed-off-by: Peter Hutterer +--- + xkb/xkb.c | 26 ++++++++++++++++++++------ + 1 file changed, 20 insertions(+), 6 deletions(-) + +diff --git a/xkb/xkb.c b/xkb/xkb.c +index 4692895db..b79a269e3 100644 +--- a/xkb/xkb.c ++++ b/xkb/xkb.c +@@ -5935,18 +5935,32 @@ ProcXkbGetKbdByName(ClientPtr client) + xkb = dev->key->xkbInfo->desc; + status = Success; + str = (unsigned char *) &stuff[1]; +- if (GetComponentSpec(&str, TRUE, &status)) /* keymap, unsupported */ +- return BadMatch; ++ { ++ char *keymap = GetComponentSpec(&str, TRUE, &status); /* keymap, unsupported */ ++ if (keymap) { ++ free(keymap); ++ return BadMatch; ++ } ++ } + names.keycodes = GetComponentSpec(&str, TRUE, &status); + names.types = GetComponentSpec(&str, TRUE, &status); + names.compat = GetComponentSpec(&str, TRUE, &status); + names.symbols = GetComponentSpec(&str, TRUE, &status); + names.geometry = GetComponentSpec(&str, TRUE, &status); +- if (status != Success) ++ if (status == Success) { ++ len = str - ((unsigned char *) stuff); ++ if ((XkbPaddedSize(len) / 4) != stuff->length) ++ status = BadLength; ++ } ++ ++ if (status != Success) { ++ free(names.keycodes); ++ free(names.types); ++ free(names.compat); ++ free(names.symbols); ++ free(names.geometry); + return status; +- len = str - ((unsigned char *) stuff); +- if ((XkbPaddedSize(len) / 4) != stuff->length) +- return BadLength; ++ } + + CHK_MASK_LEGAL(0x01, stuff->want, XkbGBN_AllComponentsMask); + CHK_MASK_LEGAL(0x02, stuff->need, XkbGBN_AllComponentsMask); +-- +2.38.1 + diff --git a/SOURCES/0001-xkb-proof-GetCountedString-against-request-length-at.patch b/SOURCES/0001-xkb-proof-GetCountedString-against-request-length-at.patch new file mode 100644 index 0000000..d358a32 --- /dev/null +++ b/SOURCES/0001-xkb-proof-GetCountedString-against-request-length-at.patch @@ -0,0 +1,35 @@ +From 11beef0b7f1ed290348e45618e5fa0d2bffcb72e Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Tue, 5 Jul 2022 12:06:20 +1000 +Subject: [PATCH xserver] xkb: proof GetCountedString against request length + attacks + +GetCountedString did a check for the whole string to be within the +request buffer but not for the initial 2 bytes that contain the length +field. A swapped client could send a malformed request to trigger a +swaps() on those bytes, writing into random memory. + +Signed-off-by: Peter Hutterer +--- + xkb/xkb.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/xkb/xkb.c b/xkb/xkb.c +index f42f59ef3..1841cff26 100644 +--- a/xkb/xkb.c ++++ b/xkb/xkb.c +@@ -5137,6 +5137,11 @@ _GetCountedString(char **wire_inout, ClientPtr client, char **str) + CARD16 len; + + wire = *wire_inout; ++ ++ if (client->req_len < ++ bytes_to_int32(wire + 2 - (char *) client->requestBuffer)) ++ return BadValue; ++ + len = *(CARD16 *) wire; + if (client->swapped) { + swaps(&len); +-- +2.38.1 + diff --git a/SOURCES/0002-Xi-return-an-error-from-XI-property-changes-if-verif.patch b/SOURCES/0002-Xi-return-an-error-from-XI-property-changes-if-verif.patch new file mode 100644 index 0000000..33bcb88 --- /dev/null +++ b/SOURCES/0002-Xi-return-an-error-from-XI-property-changes-if-verif.patch @@ -0,0 +1,41 @@ +From cb260ba95d2bb1ae98b05e289d1b7947ac409230 Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Tue, 29 Nov 2022 13:24:00 +1000 +Subject: [PATCH xserver 2/7] Xi: return an error from XI property changes if + verification failed + +Both ProcXChangeDeviceProperty and ProcXIChangeProperty checked the +property for validity but didn't actually return the potential error. + +Signed-off-by: Peter Hutterer +Acked-by: Olivier Fourdan +--- + Xi/xiproperty.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c +index a36f7d61df..68c362c628 100644 +--- a/Xi/xiproperty.c ++++ b/Xi/xiproperty.c +@@ -902,6 +902,8 @@ ProcXChangeDeviceProperty(ClientPtr client) + + rc = check_change_property(client, stuff->property, stuff->type, + stuff->format, stuff->mode, stuff->nUnits); ++ if (rc != Success) ++ return rc; + + len = stuff->nUnits; + if (len > (bytes_to_int32(0xffffffff - sizeof(xChangeDevicePropertyReq)))) +@@ -1141,6 +1143,9 @@ ProcXIChangeProperty(ClientPtr client) + + rc = check_change_property(client, stuff->property, stuff->type, + stuff->format, stuff->mode, stuff->num_items); ++ if (rc != Success) ++ return rc; ++ + len = stuff->num_items; + if (len > bytes_to_int32(0xffffffff - sizeof(xXIChangePropertyReq))) + return BadLength; +-- +2.38.1 + diff --git a/SOURCES/0003-Xi-avoid-integer-truncation-in-length-check-of-ProcX.patch b/SOURCES/0003-Xi-avoid-integer-truncation-in-length-check-of-ProcX.patch new file mode 100644 index 0000000..3d9f505 --- /dev/null +++ b/SOURCES/0003-Xi-avoid-integer-truncation-in-length-check-of-ProcX.patch @@ -0,0 +1,71 @@ +From a16f2b9693d248b81703821fd22fba8b5ba83e1a Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Tue, 29 Nov 2022 13:26:57 +1000 +Subject: [PATCH xserver 3/7] Xi: avoid integer truncation in length check of + ProcXIChangeProperty + +This fixes an OOB read and the resulting information disclosure. + +Length calculation for the request was clipped to a 32-bit integer. With +the correct stuff->num_items value the expected request size was +truncated, passing the REQUEST_FIXED_SIZE check. + +The server then proceeded with reading at least stuff->num_items bytes +(depending on stuff->format) from the request and stuffing whatever it +finds into the property. In the process it would also allocate at least +stuff->num_items bytes, i.e. 4GB. + +The same bug exists in ProcChangeProperty and ProcXChangeDeviceProperty, +so let's fix that too. + +CVE-2022-46344, ZDI-CAN 19405 + +This vulnerability was discovered by: +Jan-Niklas Sohn working with Trend Micro Zero Day Initiative + +Signed-off-by: Peter Hutterer +Acked-by: Olivier Fourdan +--- + Xi/xiproperty.c | 4 ++-- + dix/property.c | 3 ++- + 2 files changed, 4 insertions(+), 3 deletions(-) + +diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c +index 68c362c628..066ba21fba 100644 +--- a/Xi/xiproperty.c ++++ b/Xi/xiproperty.c +@@ -890,7 +890,7 @@ ProcXChangeDeviceProperty(ClientPtr client) + REQUEST(xChangeDevicePropertyReq); + DeviceIntPtr dev; + unsigned long len; +- int totalSize; ++ uint64_t totalSize; + int rc; + + REQUEST_AT_LEAST_SIZE(xChangeDevicePropertyReq); +@@ -1130,7 +1130,7 @@ ProcXIChangeProperty(ClientPtr client) + { + int rc; + DeviceIntPtr dev; +- int totalSize; ++ uint64_t totalSize; + unsigned long len; + + REQUEST(xXIChangePropertyReq); +diff --git a/dix/property.c b/dix/property.c +index 94ef5a0ec0..acce94b2c6 100644 +--- a/dix/property.c ++++ b/dix/property.c +@@ -205,7 +205,8 @@ ProcChangeProperty(ClientPtr client) + WindowPtr pWin; + char format, mode; + unsigned long len; +- int sizeInBytes, totalSize, err; ++ int sizeInBytes, err; ++ uint64_t totalSize; + + REQUEST(xChangePropertyReq); + +-- +2.38.1 + diff --git a/SOURCES/0004-Xi-disallow-passive-grabs-with-a-detail-255.patch b/SOURCES/0004-Xi-disallow-passive-grabs-with-a-detail-255.patch new file mode 100644 index 0000000..c34054b --- /dev/null +++ b/SOURCES/0004-Xi-disallow-passive-grabs-with-a-detail-255.patch @@ -0,0 +1,82 @@ +From be6bcbfa3f388ca0705db8baf10fa5c2d29b7d36 Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Tue, 29 Nov 2022 13:55:32 +1000 +Subject: [PATCH xserver 4/7] Xi: disallow passive grabs with a detail > 255 + +The XKB protocol effectively prevents us from ever using keycodes above +255. For buttons it's theoretically possible but realistically too niche +to worry about. For all other passive grabs, the detail must be zero +anyway. + +This fixes an OOB write: + +ProcXIPassiveUngrabDevice() calls DeletePassiveGrabFromList with a +temporary grab struct which contains tempGrab->detail.exact = stuff->detail. +For matching existing grabs, DeleteDetailFromMask is called with the +stuff->detail value. This function creates a new mask with the one bit +representing stuff->detail cleared. + +However, the array size for the new mask is 8 * sizeof(CARD32) bits, +thus any detail above 255 results in an OOB array write. + +CVE-2022-46341, ZDI-CAN 19381 + +This vulnerability was discovered by: +Jan-Niklas Sohn working with Trend Micro Zero Day Initiative + +Signed-off-by: Peter Hutterer +Acked-by: Olivier Fourdan +--- + Xi/xipassivegrab.c | 22 ++++++++++++++-------- + 1 file changed, 14 insertions(+), 8 deletions(-) + +diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c +index 2769fb7c94..c9ac2f8553 100644 +--- a/Xi/xipassivegrab.c ++++ b/Xi/xipassivegrab.c +@@ -137,6 +137,12 @@ ProcXIPassiveGrabDevice(ClientPtr client) + return BadValue; + } + ++ /* XI2 allows 32-bit keycodes but thanks to XKB we can never ++ * implement this. Just return an error for all keycodes that ++ * cannot work anyway, same for buttons > 255. */ ++ if (stuff->detail > 255) ++ return XIAlreadyGrabbed; ++ + if (XICheckInvalidMaskBits(client, (unsigned char *) &stuff[1], + stuff->mask_len * 4) != Success) + return BadValue; +@@ -207,14 +213,8 @@ ProcXIPassiveGrabDevice(ClientPtr client) + ¶m, XI2, &mask); + break; + case XIGrabtypeKeycode: +- /* XI2 allows 32-bit keycodes but thanks to XKB we can never +- * implement this. Just return an error for all keycodes that +- * cannot work anyway */ +- if (stuff->detail > 255) +- status = XIAlreadyGrabbed; +- else +- status = GrabKey(client, dev, mod_dev, stuff->detail, +- ¶m, XI2, &mask); ++ status = GrabKey(client, dev, mod_dev, stuff->detail, ++ ¶m, XI2, &mask); + break; + case XIGrabtypeEnter: + case XIGrabtypeFocusIn: +@@ -334,6 +334,12 @@ ProcXIPassiveUngrabDevice(ClientPtr client) + return BadValue; + } + ++ /* We don't allow passive grabs for details > 255 anyway */ ++ if (stuff->detail > 255) { ++ client->errorValue = stuff->detail; ++ return BadValue; ++ } ++ + rc = dixLookupWindow(&win, stuff->grab_window, client, DixSetAttrAccess); + if (rc != Success) + return rc; +-- +2.38.1 + diff --git a/SOURCES/0005-Xext-free-the-screen-saver-resource-when-replacing-i.patch b/SOURCES/0005-Xext-free-the-screen-saver-resource-when-replacing-i.patch new file mode 100644 index 0000000..92bb46f --- /dev/null +++ b/SOURCES/0005-Xext-free-the-screen-saver-resource-when-replacing-i.patch @@ -0,0 +1,48 @@ +From 6b59bdddf30dde413c4e0391cf84f3b94d4b4e31 Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Tue, 29 Nov 2022 14:53:07 +1000 +Subject: [PATCH xserver 5/7] Xext: free the screen saver resource when + replacing it + +This fixes a use-after-free bug: + +When a client first calls ScreenSaverSetAttributes(), a struct +ScreenSaverAttrRec is allocated and added to the client's +resources. + +When the same client calls ScreenSaverSetAttributes() again, a new +struct ScreenSaverAttrRec is allocated, replacing the old struct. The +old struct was freed but not removed from the clients resources. + +Later, when the client is destroyed the resource system invokes +ScreenSaverFreeAttr and attempts to clean up the already freed struct. + +Fix this by letting the resource system free the old attrs instead. + +CVE-2022-46343, ZDI-CAN 19404 + +This vulnerability was discovered by: +Jan-Niklas Sohn working with Trend Micro Zero Day Initiative + +Signed-off-by: Peter Hutterer +Acked-by: Olivier Fourdan +--- + Xext/saver.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Xext/saver.c b/Xext/saver.c +index f813ba08d1..fd6153c313 100644 +--- a/Xext/saver.c ++++ b/Xext/saver.c +@@ -1051,7 +1051,7 @@ ScreenSaverSetAttributes(ClientPtr client) + pVlist++; + } + if (pPriv->attr) +- FreeScreenAttr(pPriv->attr); ++ FreeResource(pPriv->attr->resource, AttrType); + pPriv->attr = pAttr; + pAttr->resource = FakeClientID(client->index); + if (!AddResource(pAttr->resource, AttrType, (void *) pAttr)) +-- +2.38.1 + diff --git a/SOURCES/0006-Xext-free-the-XvRTVideoNotify-when-turning-off-from-.patch b/SOURCES/0006-Xext-free-the-XvRTVideoNotify-when-turning-off-from-.patch new file mode 100644 index 0000000..9164d95 --- /dev/null +++ b/SOURCES/0006-Xext-free-the-XvRTVideoNotify-when-turning-off-from-.patch @@ -0,0 +1,74 @@ +From 40f06ae1bd12f4416df59382324a0d31ab2ba704 Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Wed, 30 Nov 2022 11:20:40 +1000 +Subject: [PATCH xserver 6/7] Xext: free the XvRTVideoNotify when turning off + from the same client + +This fixes a use-after-free bug: + +When a client first calls XvdiSelectVideoNotify() on a drawable with a +TRUE onoff argument, a struct XvVideoNotifyRec is allocated. This struct +is added twice to the resources: + - as the drawable's XvRTVideoNotifyList. This happens only once per + drawable, subsequent calls append to this list. + - as the client's XvRTVideoNotify. This happens for every client. + +The struct keeps the ClientPtr around once it has been added for a +client. The idea, presumably, is that if the client disconnects we can remove +all structs from the drawable's list that match the client (by resetting +the ClientPtr to NULL), but if the drawable is destroyed we can remove +and free the whole list. + +However, if the same client then calls XvdiSelectVideoNotify() on the +same drawable with a FALSE onoff argument, only the ClientPtr on the +existing struct was set to NULL. The struct itself remained in the +client's resources. + +If the drawable is now destroyed, the resource system invokes +XvdiDestroyVideoNotifyList which frees the whole list for this drawable +- including our struct. This function however does not free the resource +for the client since our ClientPtr is NULL. + +Later, when the client is destroyed and the resource system invokes +XvdiDestroyVideoNotify, we unconditionally set the ClientPtr to NULL. On +a struct that has been freed previously. This is generally frowned upon. + +Fix this by calling FreeResource() on the second call instead of merely +setting the ClientPtr to NULL. This removes the struct from the client +resources (but not from the list), ensuring that it won't be accessed +again when the client quits. + +Note that the assignment tpn->client = NULL; is superfluous since the +XvdiDestroyVideoNotify function will do this anyway. But it's left for +clarity and to match a similar invocation in XvdiSelectPortNotify. + +CVE-2022-46342, ZDI-CAN 19400 + +This vulnerability was discovered by: +Jan-Niklas Sohn working with Trend Micro Zero Day Initiative + +Signed-off-by: Peter Hutterer +Acked-by: Olivier Fourdan +--- + Xext/xvmain.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/Xext/xvmain.c b/Xext/xvmain.c +index f627471938..2a08f8744a 100644 +--- a/Xext/xvmain.c ++++ b/Xext/xvmain.c +@@ -811,8 +811,10 @@ XvdiSelectVideoNotify(ClientPtr client, DrawablePtr pDraw, BOOL onoff) + tpn = pn; + while (tpn) { + if (tpn->client == client) { +- if (!onoff) ++ if (!onoff) { + tpn->client = NULL; ++ FreeResource(tpn->id, XvRTVideoNotify); ++ } + return Success; + } + if (!tpn->client) +-- +2.38.1 + diff --git a/SOURCES/0007-xkb-reset-the-radio_groups-pointer-to-NULL-after-fre.patch b/SOURCES/0007-xkb-reset-the-radio_groups-pointer-to-NULL-after-fre.patch new file mode 100644 index 0000000..44b78dd --- /dev/null +++ b/SOURCES/0007-xkb-reset-the-radio_groups-pointer-to-NULL-after-fre.patch @@ -0,0 +1,36 @@ +From 9c70f90b24ba5de5eeb8a854c25f72a38d497fb7 Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Mon, 5 Dec 2022 15:55:54 +1000 +Subject: [PATCH xserver 7/7] xkb: reset the radio_groups pointer to NULL after + freeing it + +Unlike other elements of the keymap, this pointer was freed but not +reset. On a subsequent XkbGetKbdByName request, the server may access +already freed memory. + +CVE-2022-46283, ZDI-CAN-19530 + +This vulnerability was discovered by: +Jan-Niklas Sohn working with Trend Micro Zero Day Initiative + +Signed-off-by: Peter Hutterer +Acked-by: Olivier Fourdan +--- + xkb/xkbUtils.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c +index dd089c2046..3f5791a183 100644 +--- a/xkb/xkbUtils.c ++++ b/xkb/xkbUtils.c +@@ -1326,6 +1326,7 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst) + } + else { + free(dst->names->radio_groups); ++ dst->names->radio_groups = NULL; + } + dst->names->num_rg = src->names->num_rg; + +-- +2.38.1 + diff --git a/SOURCES/0008-Xext-fix-invalid-event-type-mask-in-XTestSwapFakeInp.patch b/SOURCES/0008-Xext-fix-invalid-event-type-mask-in-XTestSwapFakeInp.patch new file mode 100644 index 0000000..c84d387 --- /dev/null +++ b/SOURCES/0008-Xext-fix-invalid-event-type-mask-in-XTestSwapFakeInp.patch @@ -0,0 +1,35 @@ +From bb1711b7fba42f2a0c7d1c09beee241a1b2bcc30 Mon Sep 17 00:00:00 2001 +From: Peter Hutterer +Date: Mon, 19 Dec 2022 10:06:45 +1000 +Subject: [PATCH xserver] Xext: fix invalid event type mask in + XTestSwapFakeInput + +In commit b320ca0 the mask was inadvertently changed from octal 0177 to +hexadecimal 0x177. + +Fixes commit b320ca0ffe4c0c872eeb3a93d9bde21f765c7c63 + Xtest: disallow GenericEvents in XTestSwapFakeInput + +Found by Stuart Cassoff + +Signed-off-by: Peter Hutterer +--- + Xext/xtest.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Xext/xtest.c b/Xext/xtest.c +index 2985a4ce6e..dde5c4cf9d 100644 +--- a/Xext/xtest.c ++++ b/Xext/xtest.c +@@ -502,7 +502,7 @@ XTestSwapFakeInput(ClientPtr client, xReq * req) + + nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent); + for (ev = (xEvent *) &req[1]; --nev >= 0; ev++) { +- int evtype = ev->u.u.type & 0x177; ++ int evtype = ev->u.u.type & 0177; + /* Swap event */ + proc = EventSwapVector[evtype]; + /* no swapping proc; invalid event type? */ +-- +2.38.1 + diff --git a/SOURCES/xvfb-run.sh b/SOURCES/xvfb-run.sh index 9d088c1..5d4447b 100644 --- a/SOURCES/xvfb-run.sh +++ b/SOURCES/xvfb-run.sh @@ -120,7 +120,7 @@ while :; do -f|--auth-file) AUTHFILE="$2"; shift ;; -h|--help) SHOWHELP="yes" ;; -n|--server-num) SERVERNUM="$2"; shift ;; - -l|--listen-tcp) LISTENTCP="" ;; + -l|--listen-tcp) LISTENTCP="-listen tcp" ;; -p|--xauth-protocol) XAUTHPROTO="$2"; shift ;; -s|--server-args) XVFBARGS="$2"; shift ;; -w|--wait) STARTWAIT="$2"; shift ;; diff --git a/SPECS/xorg-x11-server.spec b/SPECS/xorg-x11-server.spec index 9323304..f7892c4 100644 --- a/SPECS/xorg-x11-server.spec +++ b/SPECS/xorg-x11-server.spec @@ -42,7 +42,7 @@ Summary: X.Org X11 X server Name: xorg-x11-server Version: 1.20.11 -Release: 11%{?gitdate:.%{gitdate}}%{?dist} +Release: 17%{?gitdate:.%{gitdate}}%{?dist} URL: http://www.x.org License: MIT @@ -95,6 +95,10 @@ Patch7: 0001-xkb-Drop-check-for-XkbSetMapResizeTypes.patch # 2029769 - fbdev Xorg driver no longer works as a fallback with unsupported hardware Patch8: 0001-mustard-xfree86-Disable-the-PCI-probe-path.patch +# 2148292 - Drop dependency on xorg-x11-font-utils +# Upstream MR #1001 but that one is meson only +Patch9: 0001-configure.ac-search-for-the-fontrootdir-ourselves.patch + # Backports from current stable "server-1.20-branch": # @@ -128,6 +132,28 @@ Patch10012: 0004-render-Fix-out-of-bounds-access-in-SProcRenderCompos.patch Patch10013: 0001-xkb-switch-to-array-index-loops-to-moving-pointers.patch Patch10014: 0002-xkb-swap-XkbSetDeviceInfo-and-XkbSetDeviceInfoCheck.patch Patch10015: 0003-xkb-add-request-length-validation-for-XkbSetGeometry.patch +# CVE-2022-3550 +Patch10016: 0001-xkb-proof-GetCountedString-against-request-length-at.patch +# CVE-2022-3551 +Patch10017: 0001-xkb-fix-some-possible-memleaks-in-XkbGetKbdByName.patch +# CVE-2022-46340 +Patch10018: 0001-Xtest-disallow-GenericEvents-in-XTestSwapFakeInput.patch +# related to CVE-2022-46344 +Patch10019: 0002-Xi-return-an-error-from-XI-property-changes-if-verif.patch +# CVE-2022-46344 +Patch10020: 0003-Xi-avoid-integer-truncation-in-length-check-of-ProcX.patch +# CVE-2022-46341 +Patch10021: 0004-Xi-disallow-passive-grabs-with-a-detail-255.patch +# CVE-2022-46343 +Patch10022: 0005-Xext-free-the-screen-saver-resource-when-replacing-i.patch +# CVE-2022-46342 +Patch10023: 0006-Xext-free-the-XvRTVideoNotify-when-turning-off-from-.patch +# CVE-2022-46283 +Patch10024: 0007-xkb-reset-the-radio_groups-pointer-to-NULL-after-fre.patch +# Follow-up to CVE-2022-46340 +Patch10025: 0008-Xext-fix-invalid-event-type-mask-in-XTestSwapFakeInp.patch +# CVE-2023-0494 +Patch10026: 0001-Xi-fix-potential-use-after-free-in-DeepCopyPointerCl.patch BuildRequires: make BuildRequires: systemtap-sdt-devel @@ -136,7 +162,6 @@ BuildRequires: automake autoconf libtool pkgconfig BuildRequires: xorg-x11-util-macros >= 1.17 BuildRequires: xorg-x11-proto-devel >= 7.7-10 -BuildRequires: xorg-x11-font-utils >= 7.2-11 BuildRequires: dbus-devel libepoxy-devel systemd-devel BuildRequires: xorg-x11-xtrans-devel >= 1.3.2 @@ -538,6 +563,29 @@ find %{inst_srcdir}/hw/xfree86 -name \*.c -delete %changelog +* Tue Feb 21 2023 Olivier Fourdan - 1.20.11-17 +- Fix xvfb-run script with --listen-tcp + Resolves: rhbz#2172116 + +* Wed Feb 08 2023 Peter Hutterer - 1.20.11-16 +- CVE-2023-0494 (#2166973) + +* Mon Dec 19 2022 Peter Hutterer - 1.20.11-15 +- Follow-up fix for CVE-2022-46340 (#2151776) + +* Wed Dec 14 2022 Peter Hutterer - 1.20.11-14 +- CVE fix for: CVE-2022-4283 (#2151801), CVE-2022-46340 (#2151776), + CVE-2022-46341 (#2151781), CVE-2022-46342 (#2151788), + CVE-2022-46343 (#2151791), CVE-2022-46344 (#2151798) + +* Tue Nov 29 2022 Peter Hutterer - 1.20.11-13 +- Drop dependency on xorg-x11-font-utils, it was only there for one pkgconfig + query for a variable that never changes value (#2148292) + +* Mon Nov 14 2022 Olivier Fourdan - 1.20.11-12 +- Fix CVE-2022-3550, CVE-2022-3551 + Resolves: rhbz#2140768, rhbz#2140773 + * Fri Jul 29 2022 Olivier Fourdan - 1.20.11-11 - CVE fix for: CVE-2022-2319/ZDI-CAN-16062, CVE-2022-2320/ZDI-CAN-16070 Resolves: rhbz#2108157, rhbz#2108162