From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Guo Zihao <guozh23@xiaopeng.com>
Cc: Markus Armbruster <armbru@redhat.com>,
Thomas Gleixner <tglx@kernel.org>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] Input: xen-kbdfront - bound the backend-supplied keycode
Date: Thu, 5 Nov 2026 22:21:13 -0800 [thread overview]
Message-ID: <au1xwKh4LVxHyUMW@google.com> (raw)
In-Reply-To: <20261106020217.48481-1-guozh23@xiaopeng.com>
On Fri, Nov 06, 2026 at 10:02:17AM +0800, Guo Zihao wrote:
> Keycodes arrive from the shared ring the backend writes:
>
> if (test_bit(key->keycode, info->ptr->keybit)) {
> dev = info->ptr;
> } else if (test_bit(key->keycode, info->kbd->keybit)) {
> ...
> } else {
> pr_warn("unhandled keycode 0x%x\n", key->keycode);
> return;
> }
>
> The keycode is a plain u32 from the ring page, while the keybit
> bitmaps it is tested against are sized for the KEY_CNT keycode bits
> declared to the input core. A backend that sends a keycode at or
> above KEY_CNT makes test_bit() read past the bitmap to decide which
> device gets the event, and no keycode at or above KEY_MAX is a valid
> EV_KEY code in the first place.
>
> Since the event sits in memory the backend keeps writing access to,
> the keycode must also be fetched exactly once: re-reading key->keycode
> after the bounds check would let a concurrent backend write feed an
> unchecked value to test_bit() and input_event(). Snapshot the keycode
> into a local variable with READ_ONCE() before validating it, and use
> the snapshot (as well as the already snapshotted pressed value)
> throughout.
>
> Ignore keycodes the bitmaps cannot hold.
>
> Fixes: 4ee36dc08e5c ("xen pvfb: Para-virtual framebuffer, keyboard and pointer driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guo Zihao <guozh23@xiaopeng.com>
Please explain your threat model.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2026-11-06 6:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 1:49 [PATCH] Input: xen-kbdfront - bound the backend-supplied keycode Guo Zihao
2026-11-06 1:56 ` sashiko-bot
2026-11-06 2:02 ` [PATCH v2] " Guo Zihao
2026-11-06 6:21 ` Dmitry Torokhov [this message]
2026-11-06 6:32 ` Guo Zihao
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=au1xwKh4LVxHyUMW@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=armbru@redhat.com \
--cc=guozh23@xiaopeng.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.