Find a file
Peter Hutterer 707b36b4cb 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 <peter.hutterer@who-t.net>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
(cherry picked from commit b79f32b57c)
2022-12-14 12:43:38 +10:00
.gitlab-ci ci: remove redundant slash in libxcvt repository url 2022-09-14 09:56:31 +02:00
composite Drop Xorg DDX 2022-01-18 12:09:52 +01:00
damageext Remove autotools support 2021-10-27 13:15:40 +03:00
dbe Drop Xorg DDX 2022-01-18 12:09:52 +01:00
dix dix: Skip more code in SetRootClip for ROOT_CLIP_INPUT_ONLY 2022-09-14 09:56:31 +02:00
doc Remove autotools support 2021-10-27 13:15:40 +03:00
dri3 Drop Xorg DDX 2022-01-18 12:09:52 +01:00
fb Drop Xorg DDX 2022-01-18 12:09:52 +01:00
glamor Drop Xorg DDX 2022-01-18 12:09:52 +01:00
glx Drop Xorg DDX 2022-01-18 12:09:52 +01:00
hw xwayland/input: Do not ignore leave events 2022-11-02 09:02:24 +01:00
include Drop config directory 2022-01-18 12:09:52 +01:00
m4 Add ax_pthread.m4 to m4/ 2016-05-29 19:20:51 -07:00
man Remove autotools support 2021-10-27 13:15:40 +03:00
mi Drop Xorg DDX 2022-01-18 12:09:52 +01:00
miext Drop miext/shadow directory 2022-01-18 12:09:52 +01:00
os os: print registers in the libunwind version of xorg_backtrace() 2022-07-01 10:02:16 +02:00
present Drop Xorg DDX 2022-01-18 12:09:52 +01:00
randr randr: Add "RANDR Emulation" property 2022-05-25 09:43:17 +02:00
record record: Fix out of bounds access in SwapCreateRegister() 2021-12-14 15:00:00 +02:00
render render: Fix build with gcc 12 2022-01-28 10:32:04 +01:00
test Drop Xephyr / kdrive DDX 2022-01-18 12:09:52 +01:00
Xext Xext: free the XvRTVideoNotify when turning off from the same client 2022-12-14 12:43:38 +10:00
xfixes xfixes: Fix out of bounds access in *ProcXFixesCreatePointerBarrier() 2021-12-14 15:00:01 +02:00
Xi Xi: disallow passive grabs with a detail > 255 2022-12-14 12:43:36 +10:00
xkb xkb: Avoid length-check failure on empty strings. 2022-09-14 09:56:31 +02:00
.appveyor.yml Drop Xephyr / kdrive DDX 2022-01-18 12:09:52 +01:00
.dir-locals.el .dir-locals.el: Add missing final newline 2019-10-01 17:05:28 +00:00
.gitignore .gitignore: Add new autotools file 'test-driver' 2014-04-21 13:41:42 -07:00
.gitlab-ci.yml Don't install Xvfb 2022-01-18 12:09:52 +01:00
COPYING modesetting: Merge modesetting's COPYING into the xserver's. 2014-09-15 12:46:02 -07:00
meson.build Bump version to 22.1.5 2022-11-02 10:01:42 +01:00
meson_options.txt meson: Build Xwayland unconditionally 2022-01-18 12:09:52 +01:00
README.md Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
xserver.ent.in doc: relocate xserver.ent in the package root directory 2011-05-14 11:22:26 -07:00

X Server

The X server accepts requests from client applications to create windows, which are (normally rectangular) "virtual screens" that the client program can draw into.

Windows are then composed on the actual screen by the X server (or by a separate composite manager) as directed by the window manager, which usually communicates with the user via graphical controls such as buttons and draggable titlebars and borders.

For a comprehensive overview of X Server and X Window System, consult the following article: https://en.wikipedia.org/wiki/X_server

All questions regarding this software should be directed at the Xorg mailing list:

https://lists.freedesktop.org/mailman/listinfo/xorg

The primary development code repository can be found at:

https://gitlab.freedesktop.org/xorg/xserver

For patch submission instructions, see:

https://www.x.org/wiki/Development/Documentation/SubmittingPatches

As with other projects hosted on freedesktop.org, X.Org follows its Code of Conduct, based on the Contributor Covenant. Please conduct yourself in a respectful and civilized manner when using the above mailing lists, bug trackers, etc:

https://www.freedesktop.org/wiki/CodeOfConduct