From c69b2ea1415c8a44ba9a9efc773207ecc5d075cb Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 11 Jun 2026 21:09:19 +0200 Subject: [PATCH] Xi: fix NULL pointer dereference in ProcXQueryDeviceState The handler deliberately continues when dixLookupDevice() returns BadAccess (to emit class headers with the device state blanked out). However dixLookupDevice() leaves *pDev == NULL on any non-Success return, so the subsequent "v = dev->valuator" dereferenced NULL and crashed the server. This is reachable when an XACE/SELinux hook denies the client's DixReadAccess to the device. Bail out when dev is NULL instead of dereferencing it. Fixes: 8502c06e19a4 ("xace: Fake return values on denials in input polling requests.") Fixes: 5c03d131815c ("xace: add new hooks + access controls: XInput extension.") Signed-off-by: Enrico Weigelt, metux IT consult --- Xi/queryst.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Xi/queryst.c b/Xi/queryst.c index 7bd405cdac..85a83f3dec 100644 --- a/Xi/queryst.c +++ b/Xi/queryst.c @@ -76,6 +76,13 @@ ProcXQueryDeviceState(ClientPtr client) if (rc != Success && rc != BadAccess) return rc; + /* dixLookupDevice() leaves dev NULL on anything other than Success, + * including BadAccess. The code below intentionally continues on + * BadAccess to blank out the state, but it cannot do so without a valid + * device, so bail out rather than dereferencing NULL. */ + if (!dev) + return rc; + v = dev->valuator; if (v != NULL && v->motionHintWindow != NULL) MaybeStopDeviceHint(dev, client);