Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

init: carefully handle loglevel option on kernel cmdline.

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 <alexander.sverdlin@sysgo.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexander Sverdlin and committed by
Linus Torvalds
808bf29b 32ef4384

+13 -2
+13 -2
init/main.c
··· 209 209 210 210 static int __init loglevel(char *str) 211 211 { 212 - get_option(&str, &console_loglevel); 213 - return 0; 212 + int newlevel; 213 + 214 + /* 215 + * Only update loglevel value when a correct setting was passed, 216 + * to prevent blind crashes (when loglevel being set to 0) that 217 + * are quite hard to debug 218 + */ 219 + if (get_option(&str, &newlevel)) { 220 + console_loglevel = newlevel; 221 + return 0; 222 + } 223 + 224 + return -EINVAL; 214 225 } 215 226 216 227 early_param("loglevel", loglevel);