From: Greg KH <gregkh@linuxfoundation.org>
To: Zhan Xusheng <zhanxusheng1024@gmail.com>
Cc: jirislaby@kernel.org, dmitry.torokhov@gmail.com,
mathieu.poirier@linaro.org, linux-serial@vger.kernel.org,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
zhanxusheng@xiaomi.com
Subject: Re: [PATCH v4 1/2] tty: sysrq: don't expose a partially written reset_seq
Date: Fri, 30 Oct 2026 07:05:10 +0100 [thread overview]
Message-ID: <2026103031-hungrily-compile-49c8@gregkh> (raw)
In-Reply-To: <20261030045854.153556-2-zhanxusheng1024@gmail.com>
On Fri, Oct 30, 2026 at 12:58:53PM +0800, Zhan Xusheng wrote:
> From: Zhan Xusheng <zhanxusheng@xiaomi.com>
>
> reset_seq is a module_param_array, so param_array() builds it up one
> element at a time: it resets the element count, then for each element
> calls sysrq_reset_seq_param_set(), which stores the key and bumps
> sysrq_reset_seq_version, and afterwards increments the count. Every
> intermediate step is a self-consistent sequence carrying a fresh version,
> and sysrq_handle_keypress() reparses as soon as the version moves, so
> writing 56,29,111 publishes a one-key sequence and then a two-key one
> before the intended three-key one.
>
> A key event that lands on the one-key state gives the device a one-key
> sequence, and because the parse runs before set_bit(code, key_down) the
> count is still 0 and reset_canceled is false. The same event then reaches
> sysrq_detect_reset_sequence(), where ++reset_seq_cnt matches reset_seq_len
> and sysrq_handle_reset_request() runs; sysrq_reset_downtime_ms defaults to
> 0, so sysrq_do_reset() calls orderly_reboot() straight away. Writing the
> parameter needs root and the key has to be the first one of the new
> sequence, but an administrator who presses that key while reconfiguring
> the sequence reboots the machine.
>
> Today this needs a device that has not parsed a sequence yet, because
> reset_seq_len only ever grows. The next patch resets it on every reparse,
> which without this one would expose every device.
>
> Parse the whole parameter in one callback and replace the sequence under
> a seqlock. The reader copies it out under raw_seqcount_try_begin(), as
> it runs from the input event path with interrupts disabled, and keeps
> its current sequence if a writer got in the way. It is a seqlock rather
> than a bare seqcount because writers were not serialised either:
> sysrq_of_get_keyreset_config() stores the sequence from the kernel.sysrq
> sysctl without the module parameter lock.
I'm sorry, but I can't really parse this llm-generated text. What is
the bug here. What is being fixed? And what is changing?
> Behaviour changes:
> - A key of 0 is rejected instead of silently ending the sequence there.
> - A write that fails partway keeps the previous sequence.
> - An element longer than seven characters, such as a zero-padded hex
> value, is rejected.
So what workflow hits this and will need to be changed if this patch is
applied?
> Fixes: 154b7a489a5b ("Input: sysrq - allow specifying alternate reset sequence")
no cc: stable?
And how has no one ever hit this issue in the decades that it has been
present? Is this really something that needs to be fixed? If so, why?
thanks,
greg k-h
next prev parent reply other threads:[~2026-10-30 6:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 4:58 [PATCH v4 0/2] tty: sysrq: fix the reset sequence kept per input device Zhan Xusheng
2026-10-30 4:58 ` [PATCH v4 1/2] tty: sysrq: don't expose a partially written reset_seq Zhan Xusheng
2026-10-30 6:05 ` Greg KH [this message]
2026-10-30 6:30 ` Zhan Xusheng
2026-10-30 7:02 ` Greg KH
2026-10-30 7:58 ` Zhan Xusheng
2026-10-30 8:33 ` Greg KH
2026-10-30 11:33 ` Zhan Xusheng
2026-10-30 11:48 ` Greg KH
2026-10-30 4:58 ` [PATCH v4 2/2] tty: sysrq: reset the per-device key state when reparsing reset_seq Zhan Xusheng
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=2026103031-hungrily-compile-49c8@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=mathieu.poirier@linaro.org \
--cc=zhanxusheng1024@gmail.com \
--cc=zhanxusheng@xiaomi.com \
/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
all inboxes | Powered by JetHome®