[PATCH 2/3] tweak: Allow disabling k_spec() function in drivers/tty/vt/keyboard.c
From: Tetsuo Handa
Date: Sat Apr 18 2020 - 09:39:38 EST
syzbot is reporting unexpected kernel reboots [1]. This seems to be
caused by triggering Ctrl-Alt-Del event via k_spec() function in
drivers/tty/vt/keyboard.c file, for the console output includes normal
restart sequence. Therefore, allow disabling only k_spec() function
in order to allow fuzzers to examine the remaining part in that file.
[1] https://syzkaller.appspot.com/bug?id=321861b1588b44d064b779b92293c5d55cfe8430
Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
---
drivers/tty/vt/keyboard.c | 2 ++
lib/Kconfig.tewak | 7 +++++++
2 files changed, 9 insertions(+)
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index 15d33fa0c925..f08855c4c5ba 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -633,6 +633,8 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
kbd->kbdmode == VC_OFF) &&
value != KVAL(K_SAK))
return; /* SAK is allowed even in raw mode */
+ if (IS_ENABLED(CONFIG_TWEAK_DISABLE_KBD_K_SPEC_HANDLER))
+ return;
fn_handler[value](vc);
}
diff --git a/lib/Kconfig.tewak b/lib/Kconfig.tewak
index a5ce0db67f28..a1d038bcc2a5 100644
--- a/lib/Kconfig.tewak
+++ b/lib/Kconfig.tewak
@@ -10,4 +10,11 @@ menuconfig TWEAK_KERNEL_BEHAVIOR
if TWEAK_KERNEL_BEHAVIOR
+config TWEAK_DISABLE_KBD_K_SPEC_HANDLER
+ bool "Disable k_spec() function in drivers/tty/vt/keyboard.c"
+ help
+ k_spec() function allows triggering e.g. Ctrl-Alt-Del event.
+ Such event is annoying for fuzz testing which wants to test
+ kernel code without rebooting the system.
+
endif # TWEAK_KERNEL_BEHAVIOR
--
2.18.2