forked from pool/xorg-x11-server
Stefan Dirsch
37722e6dc6
* XkbGetKbdByName use-after-free (ZDI-CAN-19530, CVE-2022-4283, bsc#1206017) - U_0001-Xtest-disallow-GenericEvents-in-XTestSwapFakeInput.patch * Server XTestSwapFakeInput stack overflow (ZDI-CAN 19265, CVE-2022-46340, bsc#1205874) - U_0002-Xi-return-an-error-from-XI-property-changes-if-verif.patch * Xi: return an error from XI property changes if verification failed (no ZDI-CAN id, no CVE id, bsc#1205875) - U_0003-Xi-avoid-integer-truncation-in-length-check-of-ProcX.patch * Server XIChangeProperty out-of-bounds access (ZDI-CAN 19405, CVE-2022-46344, bsc#1205876) - U_0004-Xi-disallow-passive-grabs-with-a-detail-255.patch * Server XIPassiveUngrabDevice out-of-bounds access (ZDI-CAN 19381, CVE-2022-46341, bsc#1205877) - U_0005-Xext-free-the-screen-saver-resource-when-replacing-i.patch * Server ScreenSaverSetAttributes use-after-free (ZDI-CAN 19404, CVE-2022-46343, bsc#1205878) - U_0006-Xext-free-the-XvRTVideoNotify-when-turning-off-from-.patch * Server XvdiSelectVideoNotify use-after-free (ZDI-CAN 19400, CVE-2022-46342, bsc#1205879) OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/xorg-x11-server?expand=0&rev=843
74 lines
2.9 KiB
Diff
74 lines
2.9 KiB
Diff
From 4ca304326d3b222a446aca82ec3c28ee8adf8446 Mon Sep 17 00:00:00 2001
|
|
From: Peter Hutterer <peter.hutterer@who-t.net>
|
|
Date: Wed, 30 Nov 2022 11:20:40 +1000
|
|
Subject: [PATCH xserver 6/6] 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.
|
|
|
|
ZDI-CAN 19400
|
|
|
|
This vulnerability was discovered by:
|
|
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
|
|
|
|
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
|
|
---
|
|
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
|
|
|