summaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorJohn Ogness <john.ogness@linutronix.de>2022-11-16 17:27:19 +0106
committerPetr Mladek <pmladek@suse.com>2022-12-02 11:24:59 +0100
commit3860e7c57fd23e744e045436f9872fb9d01381e2 (patch)
tree1e3b1edbb9eff00d99f8ad6a37d2bbcd3b8a5cdc /arch/um
parenta42427609368d773c4ab6b4c9686577817a4d219 (diff)
downloadlinux-3860e7c57fd23e744e045436f9872fb9d01381e2.tar.bz2
um: kmsg_dump: only dump when no output console available
The initial intention of the UML kmsg_dumper is to dump the kernel buffers to stdout if there is no console available to perform the regular crash output. However, if ttynull was registered as a console, no crash output was seen. Commit e23fe90dec28 ("um: kmsg_dumper: always dump when not tty console") tried to fix this by performing the kmsg_dump unless the stdio console was behind /dev/console or enabled. But this allowed kmsg dumping to occur even if other non-stdio consoles will output the crash output. Also, a console being the driver behind /dev/console has nothing to do with a crash scenario. Restore the initial intention by dumping the kernel buffers to stdout only if a non-ttynull console is registered and enabled. Also add detailed comments so that it is clear why these rules are applied. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20221116162152.193147-8-john.ogness@linutronix.de
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/kernel/kmsg_dump.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/arch/um/kernel/kmsg_dump.c b/arch/um/kernel/kmsg_dump.c
index 0224fcb36e22..40abf1e9ccb1 100644
--- a/arch/um/kernel/kmsg_dump.c
+++ b/arch/um/kernel/kmsg_dump.c
@@ -17,13 +17,22 @@ static void kmsg_dumper_stdout(struct kmsg_dumper *dumper,
unsigned long flags;
size_t len = 0;
- /* only dump kmsg when no console is available */
+ /*
+ * If no consoles are available to output crash information, dump
+ * the kmsg buffer to stdout.
+ */
+
if (!console_trylock())
return;
for_each_console(con) {
- if(strcmp(con->name, "tty") == 0 &&
- (con->flags & (CON_ENABLED | CON_CONSDEV)) != 0) {
+ /*
+ * The ttynull console and disabled consoles are ignored
+ * since they cannot output. All other consoles are
+ * expected to output the crash information.
+ */
+ if (strcmp(con->name, "ttynull") != 0 &&
+ (con->flags & CON_ENABLED)) {
break;
}
}