Fix deadlock in XRebindKeysym()

Resolves: https://issues.redhat.com/browse/RHEL-45855
This commit is contained in:
José Expósito 2024-07-05 09:35:53 +02:00
parent e728f1572c
commit 403255c136
2 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,52 @@
From 751fbc59c30604980fdd19cb4b333d3cf2eccb24 Mon Sep 17 00:00:00 2001
From: Olivier Fourdan <ofourdan@redhat.com>
Date: Fri, 21 Jun 2024 14:37:24 +0200
Subject: [PATCH] Fix deadlock in XRebindKeysym()
Xlib is now built with threading support enabled from the constructor
by default.
XRebindKeysym() acquires the display lock, then calls:
| XRebindKeysym()
| LockDisplay()
| ComputeMaskFromKeytrans()
| -> XkbKeysymToModifiers()
| -> _XkbLoadDpy()
| -> XkbGetMap()
| -> XkbGetUpdatedMap()
| LockDisplay()
And the dead lock:
| Xlib ERROR: XKBGetMap.c line 575 thread 1fc6e580: locking display already
| locked at KeyBind.c line 937
To avoid the issue, call ComputeMaskFromKeytrans() from outside the display
lock.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/lib/libx11/-/issues/216
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/256>
---
src/KeyBind.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/KeyBind.c b/src/KeyBind.c
index a8181b91..a5e22131 100644
--- a/src/KeyBind.c
+++ b/src/KeyBind.c
@@ -958,8 +958,9 @@ XRebindKeysym (
memcpy ((char *) p->modifiers, (char *) mlist, (size_t) nb);
p->key = keysym;
p->mlen = nm;
- ComputeMaskFromKeytrans(dpy, p);
UnlockDisplay(dpy);
+ ComputeMaskFromKeytrans(dpy, p);
+
return 0;
}
--
2.45.2

View File

@ -5,7 +5,7 @@
Summary: Core X11 protocol client library
Name: libX11
Version: 1.8.7
Release: 6%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist}
Release: 7%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist}
License: MIT AND X11
URL: http://www.x.org
@ -33,6 +33,9 @@ Patch09: 0004-XKBMAlloc-Check-that-needed-is-0-in-XkbResizeKeyActi.patch
Patch10: 0005-Fix-memory-leak-in-_XimProtoSetIMValues.patch
Patch11: 0006-Fix-buffer-overrun-in-parse_omit_name.patch
# https://issues.redhat.com/browse/RHEL-45855
Patch12: 0001-Fix-deadlock-in-XRebindKeysym.patch
BuildRequires: libtool
BuildRequires: make
BuildRequires: xorg-x11-util-macros >= 1.11
@ -136,6 +139,10 @@ make %{?_smp_mflags} check
%{_mandir}/man5/*.5*
%changelog
* Fri Jul 05 2024 José Expósito <jexposit@redhat.com> - 1.8.7-7
- Fix deadlock in XRebindKeysym()
Resolves: https://issues.redhat.com/browse/RHEL-45855
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 1.8.7-6
- Bump release for June 2024 mass rebuild