From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Anthony Liguori <aliguori@us.ibm.com>,
Markus Armbruster <armbru@redhat.com>,
Juergen Gross <jgross@suse.com>,
Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 06/10] Input: xen-kbdfront - check info->ptr and info->kbd before dereferencing
Date: Fri, 27 Nov 2026 20:10:00 +0000 [thread overview]
Message-ID: <20261127201050.3532488-7-lee@kernel.org> (raw)
In-Reply-To: <20261127201050.3532488-1-lee@kernel.org>
When XenStore disables either the pointer or keyboard device,
xenkbd_probe() leaves info->ptr or info->kbd as NULL.
xenkbd_handle_key_event() dereferences info->ptr->keybit and
info->kbd->keybit before checking whether those pointers are valid,
causing a NULL pointer dereference in interrupt context on key events.
Check info->ptr and info->kbd before testing their keybit masks and
remove the unreachable NULL check below.
Fixes: 3ef8a2eeb6dc ("Input: xen-kbdfront - allow better run-time configuration")
Closes: https://sashiko.dev/#/bug/linux-9e0f9c2c-45ab-4045-80b4-47629154e917
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/input/misc/xen-kbdfront.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index 6471d836f6fe..4e0bd4480f83 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -92,9 +92,9 @@ static void xenkbd_handle_key_event(struct xenkbd_info *info,
struct input_dev *dev;
int value = key->pressed;
- if (test_bit(key->keycode, info->ptr->keybit)) {
+ if (info->ptr && test_bit(key->keycode, info->ptr->keybit)) {
dev = info->ptr;
- } else if (test_bit(key->keycode, info->kbd->keybit)) {
+ } else if (info->kbd && test_bit(key->keycode, info->kbd->keybit)) {
dev = info->kbd;
if (key->pressed && test_bit(key->keycode, info->kbd->key))
value = 2; /* Mark as autorepeat */
@@ -103,9 +103,6 @@ static void xenkbd_handle_key_event(struct xenkbd_info *info,
return;
}
- if (unlikely(!dev))
- return;
-
input_event(dev, EV_KEY, key->keycode, value);
input_sync(dev);
}
--
2.56.1.839.g22a8290db9-goog
next prev parent reply other threads:[~2026-11-27 20:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 20:09 [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2) Lee Jones
2026-11-27 20:09 ` [PATCH 01/10] Input: adi - prevent off-by-one write in adi_read_packet() Lee Jones
2026-11-27 20:09 ` [PATCH 02/10] Input: adi - validate axis and button counts in adi_id_decode() Lee Jones
2026-11-27 20:09 ` [PATCH 03/10] Input: xpad - cancel presence work on xpad360w_start_input() failure Lee Jones
2026-11-27 20:24 ` sashiko-bot
2026-11-27 20:09 ` [PATCH 04/10] Input: aw86927 - use devm_work_autocancel() for haptics play work Lee Jones
2026-11-27 20:09 ` [PATCH 05/10] Input: stmfts - fix i2c_smbus_read_i2c_block_data() check in status sysfs Lee Jones
2026-11-27 20:35 ` David Heidelberg
2026-11-27 20:10 ` Lee Jones [this message]
2026-11-27 20:10 ` [PATCH 07/10] Input: drv2665 - disable haptics work across suspend and resume Lee Jones
2026-11-27 20:10 ` [PATCH 08/10] Input: drv2667 " Lee Jones
2026-11-27 20:10 ` [PATCH 09/10] Input: goodix_berlin_i2c - check i2c_get_match_data() for NULL Lee Jones
2026-11-27 20:10 ` [PATCH 10/10] Input: goodix_berlin_spi - validate ic_data and SPI max transfer size Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127201050.3532488-7-lee@kernel.org \
--to=lee@kernel.org \
--cc=aliguori@us.ibm.com \
--cc=armbru@redhat.com \
--cc=dmitry.torokhov@gmail.com \
--cc=jgross@suse.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleksandr_andrushchenko@epam.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox