Skip to content

Commit 808bf29

Browse files
Alexander Sverdlintorvalds
authored andcommitted
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 <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 32ef438 commit 808bf29

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

init/main.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,19 @@ early_param("quiet", quiet_kernel);
209209

210210
static int __init loglevel(char *str)
211211
{
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;
214225
}
215226

216227
early_param("loglevel", loglevel);

0 commit comments

Comments
 (0)