From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Rahul Priolkar <rahul.priolkar@asu.edu>
Cc: Jiri Slaby <jirislaby@kernel.org>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-input@vger.kernel.org
Subject: Re: [PATCH] tty: sysrq: serialize sysrq_toggle_support()
Date: Wed, 2 Dec 2026 10:47:57 +0100 [thread overview]
Message-ID: <2026120219-colonize-pouring-2b95@gregkh> (raw)
In-Reply-To: <6b0fe37a.fa539071.2f0826.409f@mx.google.com>
On Wed, Dec 02, 2026 at 01:23:06AM -0800, Rahul Priolkar wrote:
> 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);
Why WRITE_ONCE if you have a mutex?
And you have a mutex that only works for writing?
what exactly is the "bug" here you are trying to fix?
confused,
greg k-h
next prev parent reply other threads:[~2026-12-02 9:48 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 ` [PATCH] tty: sysrq: serialize sysrq_toggle_support() Rahul Priolkar
2026-12-02 9:36 ` sashiko-bot
2026-12-02 9:47 ` Greg Kroah-Hartman [this message]
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=2026120219-colonize-pouring-2b95@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jirislaby@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=rahul.priolkar@asu.edu \
/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.