init: Carefuly handle loglevel option passed to kernel cmdline
PATCH 1/1 init: Carefuly handle loglevel option passed to kernel cmdline
From: Alexander Sverdlin <[email protected]>
Carefuly handle loglevel option passed to kernel cmdline.
When malformed loglevel value (for example "${abc}") passed to kernel cmdline, the loglevel itself is being set to 0. This suppresses all following messages, including all the errors and crashes caused by other malformed cmdline options. This could make debugging process quite tricky. Provided modifications leaves previous value of loglevel if the new value is incorrect and report error code in this case.
Signed-off-by Alexander Sverdlin <[email protected]>
---
init/main.c +13 -2
@@ -209,8 +209,19 @@ early_param("quiet", quiet_kernel);static int __init loglevel (char *str) { -get_option (&str, &console_loglevel); -return 0 ; +int tmp_loglevel; + +/* +* Only update loglevel value when correct setting was passed, +* to prevent blind crashes (when loglevel being set to 0) that +* are quite hard to debug +*/ +if (get_option (&str, &tmp_loglevel)) { + console_loglevel = tmp_loglevel; +return 0 ; + } + +return -EINVAL ; }early_param ("loglevel" , loglevel);