Skip to content

Commit

Permalink
um: kmsg_dump: only dump when no output console available
Browse files Browse the repository at this point in the history
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 e23fe90 ("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 <[email protected]>
Reviewed-by: Petr Mladek <[email protected]>
Signed-off-by: Petr Mladek <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
jogness authored and pmladek committed Dec 2, 2022
1 parent a424276 commit 3860e7c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions arch/um/kernel/kmsg_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 3860e7c

Please sign in to comment.