xserver/render
Olivier Fourdan 0885e0b262 render: Avoid 0 or less animated cursors
Animated cursors use a series of cursors that the client can set.

By default, the Xserver assumes at least one cursor is specified
while a client may actually pass no cursor at all.

That causes an out-of-bound read creating the animated cursor and a
crash of the Xserver:

 | Invalid read of size 8
 |    at 0x5323F4: AnimCursorCreate (animcur.c:325)
 |    by 0x52D4C5: ProcRenderCreateAnimCursor (render.c:1817)
 |    by 0x52DC80: ProcRenderDispatch (render.c:1999)
 |    by 0x4A1E9D: Dispatch (dispatch.c:560)
 |    by 0x4B0169: dix_main (main.c:284)
 |    by 0x4287F5: main (stubmain.c:34)
 |  Address 0x59aa010 is 0 bytes after a block of size 0 alloc'd
 |    at 0x48468D3: reallocarray (vg_replace_malloc.c:1803)
 |    by 0x52D3DA: ProcRenderCreateAnimCursor (render.c:1802)
 |    by 0x52DC80: ProcRenderDispatch (render.c:1999)
 |    by 0x4A1E9D: Dispatch (dispatch.c:560)
 |    by 0x4B0169: dix_main (main.c:284)
 |    by 0x4287F5: main (stubmain.c:34)
 |
 | Invalid read of size 2
 |    at 0x5323F7: AnimCursorCreate (animcur.c:325)
 |    by 0x52D4C5: ProcRenderCreateAnimCursor (render.c:1817)
 |    by 0x52DC80: ProcRenderDispatch (render.c:1999)
 |    by 0x4A1E9D: Dispatch (dispatch.c:560)
 |    by 0x4B0169: dix_main (main.c:284)
 |    by 0x4287F5: main (stubmain.c:34)
 |  Address 0x8 is not stack'd, malloc'd or (recently) free'd

To avoid the issue, check the number of cursors specified and return a
BadValue error in both the proc handler (early) and the animated cursor
creation (as this is a public function) if there is 0 or less cursor.

CVE-2025-49175

This issue was discovered by Nils Emmerich <nemmerich@ernw.de> and
reported by Julian Suleder via ERNW Vulnerability Disclosure.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: José Expósito <jexposit@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2024>
2025-06-17 14:18:58 +02:00
..
animcur.c render: Avoid 0 or less animated cursors 2025-06-17 14:18:58 +02:00
filter.c drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
glyph.c Revert "os: move BUG_*() macros to own private header" 2025-06-13 17:13:54 -07:00
glyphstr.h render: move private definitions out of public glyphstr.h 2024-03-03 22:54:16 +00:00
glyphstr_priv.h render: fix refcounting of glyphs during ProcRenderAddGlyphs 2024-04-02 19:19:40 -07:00
matrix.c drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
meson.build meson: hide C API if Xorg is disabled (like autotools) 2021-03-11 00:22:36 +00:00
miindex.c render: miindex.c does not need header guard macros 2025-04-19 17:02:16 +00:00
mipict.c render: use dixDestroyPixmap() instead of direct driver call 2025-02-12 17:48:30 +01:00
mipict.h render: Hide/unexport some implementation details 2015-07-08 16:40:57 -04:00
mirect.c drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
mitrap.c drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
mitri.c drop obsolete HAVE_DIX_CONFIG_H 2024-10-10 13:38:31 +00:00
picture.c render: use dixDestroyPixmap() instead of direct driver call 2025-02-12 17:48:30 +01:00
picture.h glamor: fix CbCr format handling 2022-12-01 08:41:57 +00:00
picturestr.h render: picturestr.h: re-add compat macros for intel driver 2025-02-11 09:53:59 +01:00
picturestr_priv.h rename old symbol PANORAMIX to XINERAMA 2025-02-06 15:51:27 +00:00
render.c render: Avoid 0 or less animated cursors 2025-06-17 14:18:58 +02:00