From: Rahul Priolkar <rahul.priolkar@asu.edu>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-input@vger.kernel.org
Subject: [PATCH] tty: sysrq: serialize sysrq_toggle_support()
Date: Wed, 02 Dec 2026 01:23:06 -0800 (PST) [thread overview]
Message-ID: <6b0fe37a.fa539071.2f0826.409f@mx.google.com> (raw)
In-Reply-To: <2026120242-corridor-chase-3d79@gregkh>
Hi,
Thanks for the response. Here's the patch.
-- >8 --
Concurrent enable-mask updates in sysrq_toggle_support() can both
register the static SysRq input handler, corrupting input_handler_list.
Serialize the mask update and the corresponding handler registration or
unregistration with a mutex. Both callers run in process context.
Fixes: 97f5f0cd8cd0 ("Input: implement SysRq as a separate input handler")
Cc: stable@vger.kernel.org
Signed-off-by: Rahul Priolkar <rahul.priolkar@asu.edu>
---
drivers/tty/sysrq.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index f4571d05b..882d7ae43 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -1100,11 +1100,17 @@ static inline void sysrq_unregister_handler(void)
#endif /* CONFIG_INPUT */
+/* Serializes enable-mask updates with the handler (un)registration they imply. */
+static DEFINE_MUTEX(sysrq_toggle_mutex);
+
int sysrq_toggle_support(int enable_mask)
{
- bool was_enabled = sysrq_on();
+ bool was_enabled;
- sysrq_enabled = enable_mask;
+ guard(mutex)(&sysrq_toggle_mutex);
+
+ was_enabled = sysrq_on();
+ WRITE_ONCE(sysrq_enabled, enable_mask);
if (was_enabled != sysrq_on()) {
if (sysrq_on())
--
2.56.0
next prev parent reply other threads:[~2026-12-02 9:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 8:18 [BUG] tty: sysrq: duplicate input handler registration on v7.4-rc5 Rahul Priolkar
2026-12-02 9:00 ` Greg Kroah-Hartman
2026-12-02 9:23 ` Rahul Priolkar [this message]
2026-12-02 9:36 ` [PATCH] tty: sysrq: serialize sysrq_toggle_support() sashiko-bot
2026-12-02 9:47 ` Greg Kroah-Hartman
2026-12-02 9:57 ` Greg Kroah-Hartman
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=6b0fe37a.fa539071.2f0826.409f@mx.google.com \
--to=rahul.priolkar@asu.edu \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@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 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.