Skip to content

Commit

Permalink
init: carefully handle loglevel option on kernel cmdline.
Browse files Browse the repository at this point in the history
When a malformed loglevel value (for example "${abc}") is passed on the
kernel cmdline, the loglevel itself is being set to 0.

That then suppresses all following messages, including all the errors
and crashes caused by other malformed cmdline options.  This could make
debugging process quite tricky.

This patch leaves the previous value of loglevel if the new value is
incorrect and reports an error code in this case.

Signed-off-by: Alexander Sverdlin <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Alexander Sverdlin authored and torvalds committed Sep 21, 2011
1 parent 32ef438 commit 808bf29
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,19 @@ early_param("quiet", quiet_kernel);

static int __init loglevel(char *str)
{
get_option(&str, &console_loglevel);
return 0;
int newlevel;

/*
* Only update loglevel value when a correct setting was passed,
* to prevent blind crashes (when loglevel being set to 0) that
* are quite hard to debug
*/
if (get_option(&str, &newlevel)) {
console_loglevel = newlevel;
return 0;
}

return -EINVAL;
}

early_param("loglevel", loglevel);
Expand Down

0 comments on commit 808bf29

Please sign in to comment.