]> git.baikalelectronics.ru Git - kernel.git/commit
x86/nmi: Make register_nmi_handler() more robust
authorThomas Gleixner <tglx@linutronix.de>
Sun, 15 May 2022 11:39:34 +0000 (13:39 +0200)
committerBorislav Petkov <bp@suse.de>
Tue, 17 May 2022 07:25:25 +0000 (09:25 +0200)
commite9651dce3280ccc0623fbf1c6d75424b42596f4e
treef915d1b77fa76c9d4ef18b0c3f7a0164665e97dc
parent2355821028aac1279c7a106c87561c658f1a11f2
x86/nmi: Make register_nmi_handler() more robust

register_nmi_handler() has no sanity check whether a handler has been
registered already. Such an unintended double-add leads to list corruption
and hard to diagnose problems during the next NMI handling.

Init the list head in the static NMI action struct and check it for being
empty in register_nmi_handler().

  [ bp: Fixups. ]

Reported-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/lkml/20220511234332.3654455-1-seanjc@google.com
arch/x86/include/asm/nmi.h
arch/x86/kernel/nmi.c