From: Zhan Xusheng <zhanxusheng1024@gmail.com>
To: gregkh@linuxfoundation.org, jirislaby@kernel.org
Cc: 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: [PATCH v4 0/2] tty: sysrq: fix the reset sequence kept per input device
Date: Fri, 30 Oct 2026 12:58:52 +0800 [thread overview]
Message-ID: <20261030045854.153556-1-zhanxusheng1024@gmail.com> (raw)
From: Zhan Xusheng <zhanxusheng@xiaomi.com>
v3 1/2 was wrong and is dropped. It stopped a truncated parse from being
cached, but the parse still reached sysrq_detect_reset_sequence() in the
same call and could complete a reset. param_array() publishes every
intermediate sequence with a fresh version, so no reader-side check can
tell them from the final one; 1/2 now parses the whole parameter in one
callback and replaces it under a seqlock. 2/2 is the same fix adapted to
the new 1/2, and depends on it.
Both fix bugs from the same 2013 commit and apply to every stable tree,
but 1/2 is over the 100-line limit in stable-kernel-rules.rst, so I left
the stable tags out. The two have to go together.
Tested in QEMU with a uinput keyboard, one device per scenario so the
per-device state survives the parameter writes:
before after
hold the full sequence reboots reboots
hold one key of two no no
hold the old sequence after a rewrite no no
0x3b,0x3c reboots reboots
hold the new sequence after a rewrite no reboots
release a stale key, then hold the new no reboots
press key 1 while the write is mid-way reboots no
The last row needs a 500 ms delay to widen the window, in
sysrq_reset_seq_param_set() before the series and inside the seqlock
section after it. Without 2/2's timer_delete() the armed reset survives
the replacement and fires. Rejected input is the same apart from the
two cases listed in 1/2, and reset_seq reads back the same.
Changes in v4:
- Dropped v3 1/2 and replaced it with the seqlock patch (Sashiko flagged
the window on v3 1/2).
- Reject KEY_RESERVED in the parameter instead of storing it.
- Dropped the stable tags.
- Tested in QEMU rather than by inspection only.
Changes in v3:
- Added a first patch so that a truncated parse no longer sticks
(Sashiko).
- Added Fixes: to both patches.
Changes in v2:
- Retitled from "Input:" to "tty: sysrq:" (Greg Kroah-Hartman).
- Delete keyreset_timer, otherwise an already armed reset survives the
reparse (Sashiko).
v3: https://lore.kernel.org/all/20261021022007.1717207-1-zhanxusheng1024@gmail.com/
v2: https://lore.kernel.org/all/20261016070636.2559899-1-zhanxusheng@xiaomi.com/
v1: https://lore.kernel.org/all/20261016032732.2328852-1-zhanxusheng@xiaomi.com/
Zhan Xusheng (2):
tty: sysrq: don't expose a partially written reset_seq
tty: sysrq: reset the per-device key state when reparsing reset_seq
drivers/tty/sysrq.c | 142 +++++++++++++++++++++++++++++++++-----------
1 file changed, 107 insertions(+), 35 deletions(-)
base-commit: c339f4010dea8b0d754f84ace70cd1b089878ef8
--
2.43.0
next reply other threads:[~2026-10-30 4:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 4:58 Zhan Xusheng [this message]
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
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=20261030045854.153556-1-zhanxusheng1024@gmail.com \
--to=zhanxusheng1024@gmail.com \
--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 \
--cc=mathieu.poirier@linaro.org \
--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®