From 6172bd2b41a7ce158b9052af3e373318e5e4381c Mon Sep 17 00:00:00 2001 From: Alex Goins Date: Thu, 2 Jul 2020 18:39:11 -0500 Subject: [PATCH 1/3] randr: Check rrPrivKey before autobinding GPU screens RRProviderAutoConfigGpuScreen() is called from outside RandR, so there is no guarantee that RandR has been initialized when it is called. As mentioned in commit 4226c6d, it's possible that RandR has not been initialized if the server is configured with Xinerama and there is more than one X screen. Calling rrGetScrPriv when RandR isn't initialized causes an assertion failure that aborts the server: Xorg: ../include/privates.h:121: dixGetPrivateAddr: Assertion key->initialized' failed. Just as in commit 4226c6d, fix the problem by checking dixPrivateKeyRegistered(rrPrivKey) before calling rrGetScrPriv. Signed-off-by: Alex Goins --- randr/rrprovider.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/randr/rrprovider.c b/randr/rrprovider.c index 217aead56..617185cf7 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -490,10 +490,20 @@ RRDeliverProviderEvent(ClientPtr client, WindowPtr pWin, RRProviderPtr provider) void RRProviderAutoConfigGpuScreen(ScreenPtr pScreen, ScreenPtr primaryScreen) { - rrScrPrivPtr pScrPriv = rrGetScrPriv(pScreen); - rrScrPrivPtr primaryPriv = rrGetScrPriv(primaryScreen); - RRProviderPtr provider = pScrPriv->provider; - RRProviderPtr primary_provider = primaryPriv->provider; + rrScrPrivPtr pScrPriv; + rrScrPrivPtr primaryPriv; + RRProviderPtr provider; + RRProviderPtr primary_provider; + + /* Bail out if RandR wasn't initialized. */ + if (!dixPrivateKeyRegistered(rrPrivKey)) + return; + + pScrPriv = rrGetScrPriv(pScreen); + primaryPriv = rrGetScrPriv(primaryScreen); + + provider = pScrPriv->provider; + primary_provider = primaryPriv->provider; if (!provider || !primary_provider) return; -- GitLab From 8eeff5d7880c6885ee6f206355599f13d739afa7 Mon Sep 17 00:00:00 2001 From: Alex Goins Date: Thu, 2 Jul 2020 20:12:43 -0500 Subject: [PATCH 2/3] randr: Check rrPrivKey in RRHasScanoutPixmap() RRHasScanoutPixmap() is called from xf86CheckHWCursor(), regardless of whether or not RandR has been initialized. As mentioned in commit 4226c6d, it's possible that RandR has not been initialized if the server is configured with Xinerama and there is more than one X screen. Calling rrGetScrPriv when RandR isn't initialized causes an assertion failure that aborts the server: Xorg: ../include/privates.h:121: dixGetPrivateAddr: Assertion key->initialized' failed. Just as in commit 4226c6d, fix the problem by checking dixPrivateKeyRegistered(rrPrivKey) before calling rrGetScrPriv. Signed-off-by: Alex Goins --- randr/rrcrtc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 517cdf00a..c8626b982 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -2012,9 +2012,15 @@ RRReplaceScanoutPixmap(DrawablePtr pDrawable, PixmapPtr pPixmap, Bool enable) Bool RRHasScanoutPixmap(ScreenPtr pScreen) { - rrScrPriv(pScreen); + rrScrPrivPtr pScrPriv; int i; + /* Bail out if RandR wasn't initialized. */ + if (!dixPrivateKeyRegistered(rrPrivKey)) + return FALSE; + + pScrPriv = rrGetScrPriv(pScreen); + if (!pScreen->is_output_secondary) return FALSE; -- GitLab From 495bf63a7df066672d9d44dedeb1f49658a247d8 Mon Sep 17 00:00:00 2001 From: Alex Goins Date: Thu, 2 Jul 2020 20:03:06 -0500 Subject: [PATCH 3/3] randr: Re-add removed NULL checks to xf86RandR12.c Commit 1e3f9ea1 removed some NULL checks from xf86RandR12.c, on the premise that they can't be reached unless RandR has already been initialized. For threesuch calls, that's not true: xf86Crtc.c::xf86CrtcScreenInit(): if (c == config->num_crtc) { xf86RandR12SetRotations(screen, RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270 | RR_Reflect_X | RR_Reflect_Y); xf86RandR12SetTransformSupport(screen, TRUE); } else { xf86RandR12SetRotations(screen, RR_Rotate_0); xf86RandR12SetTransformSupport(screen, FALSE); } xf86Crtc.c::xf86CrtcCloseScreen(): xf86RandR12CloseScreen(screen); This change adds checks back to xf86RandR12Set{Rotations,TransformSupport}() and xf86RandR12CloseScreen(), checking that xf86RandR12KeyRec has been registered. Without this, X will hit an assert that causes it to abort. Signed-off-by: Alex Goins --- hw/xfree86/modes/xf86RandR12.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 08b8d66d8..50cbd043e 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -901,6 +901,9 @@ xf86RandR12CloseScreen(ScreenPtr pScreen) { XF86RandRInfoPtr randrp; + if (!dixPrivateKeyRegistered(&xf86RandR12KeyRec)) + return; + randrp = XF86RANDRINFO(pScreen); #if RANDR_12_INTERFACE xf86ScreenToScrn(pScreen)->EnterVT = randrp->orig_EnterVT; @@ -922,6 +925,9 @@ xf86RandR12SetRotations(ScreenPtr pScreen, Rotation rotations) xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); #endif + if (!dixPrivateKeyRegistered(&xf86RandR12KeyRec)) + return; + randrp = XF86RANDRINFO(pScreen); #if RANDR_12_INTERFACE for (c = 0; c < config->num_crtc; c++) { @@ -941,6 +947,9 @@ xf86RandR12SetTransformSupport(ScreenPtr pScreen, Bool transforms) int c; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + if (!dixPrivateKeyRegistered(&xf86RandR12KeyRec)) + return; + for (c = 0; c < config->num_crtc; c++) { xf86CrtcPtr crtc = config->crtc[c]; -- GitLab