[PATCH] tty: sysrq: Fix missing SYSRQ_ENABLE_DUMP mask on 'q' and 'd' keys

From: Ian Rogers

Date: Thu Dec 03 2026 - 12:18:26 EST


Both sysrq_show_timers_op ('q', show-all-timers) and sysrq_showlocks_op
('d', show-all-locks) are diagnostic dump operations, just like 'l',
'p', 't', 'w', 'm', and 'z', which all set SYSRQ_ENABLE_DUMP (0x8).

Because .enable_mask was omitted in sysrq_show_timers_op and
sysrq_showlocks_op, it defaulted to 0. When /proc/sys/kernel/sysrq is
configured with a bitmask (> 1) such as 0x8 (SYSRQ_ENABLE_DUMP),
sysrq_on_mask(0) evaluates (sysrq_enabled & 0) == 0, preventing 'q' and
'd' from working via SysRq key combinations unless all SysRq functions
are unconditionally enabled (sysrq == 1).

Found with Clang's require_explicit_initialization attribute on
struct sysrq_key_op.

Fixes: 88ad0bf68905 ("[PATCH] Add SysRq-Q to print timer_list debug info")
Fixes: de5097c2e73f ("[PATCH] mutex subsystem, more debugging code")
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
Note: Found using Clang's require_explicit_initialization attribute;
an AI coding assistant helped audit call sites, verify Fixes commits,
and draft the changelog.

drivers/tty/sysrq.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index f4571d05b496..068fea418af5 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -195,6 +195,7 @@ static const struct sysrq_key_op sysrq_show_timers_op = {
.handler = sysrq_handle_show_timers,
.help_msg = "show-all-timers(q)",
.action_msg = "Show clockevent devices & pending hrtimers (no others)",
+ .enable_mask = SYSRQ_ENABLE_DUMP,
};

static void sysrq_handle_mountro(u8 key)
@@ -218,6 +219,7 @@ static const struct sysrq_key_op sysrq_showlocks_op = {
.handler = sysrq_handle_showlocks,
.help_msg = "show-all-locks(d)",
.action_msg = "Show Locks Held",
+ .enable_mask = SYSRQ_ENABLE_DUMP,
};
#else
#define sysrq_showlocks_op (*(const struct sysrq_key_op *)NULL)

base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
--
2.56.1.839.g22a8290db9-goog