Re: [BUG] tty: sysrq: duplicate input handler registration on v7.4-rc5
From: Greg Kroah-Hartman
Date: Wed Dec 02 2026 - 04:01:12 EST
On Wed, Dec 02, 2026 at 12:18:32AM -0800, Rahul Priolkar wrote:
> Hello,
>
> On Linux v7.4-rc5 (fe6ff8d5d675), we observed duplicate entries for
> the SysRq input handler on a defconfig-based x86_64 guest. In each
> trial, we updated kernel.sysrq and checked /proc/bus/input/handlers
> for exactly one SysRq entry. With concurrent updates, the handler
> appeared 60 times in one listing after 98 trials. Updating kernel.sysrq
> requires root in the initial user namespace.
>
> Our reading of drivers/tty/sysrq.c is that sysrq_toggle_support() can
> register the static handler twice because the enable-state check and
> registration are not serialized. Does that match your understanding of
> the failure?
>
> A debug build with DEBUG_LIST and BUG_ON_DATA_CORRUPTION stopped in
> the first run. The relevant frames were:
>
> kernel BUG at lib/list_debug.c:37!
> RIP: 0010:__list_add_valid_or_report
> input_register_handler
> sysrq_register_handler
> sysrq_sysctl_handler
>
> On the unmodified kernel, we ran the updates one at a time as a
> control. All 3,000 trials showed exactly one handler entry. We then
> tested an rc5 build that included a mutex around sysrq_toggle_support()
> along with our other candidate fixes. Across 6,000 concurrent-update
> trials, we saw no duplicate entries or kernel warnings. I can share
> the candidate patch if useful.
Always send a patch.