Skip to content

Commit b665eae

Browse files
rddunlappmladek
authored andcommitted
printk: fix return value of printk.devkmsg __setup handler
If an invalid option value is used with "printk.devkmsg=<value>", it is silently ignored. If a valid option value is used, it is honored but the wrong return value (0) is used, indicating that the command line option had an error and was not handled. This string is not added to init's environment strings due to init/main.c::unknown_bootoption() checking for a '.' in the boot option string and then considering that string to be an "Unused module parameter". Print a warning message if a bad option string is used. Always return 1 from the __setup handler to indicate that the command line option has been handled. Fixes: 750afe7 ("printk: add kernel parameter to control writes to /dev/kmsg") Signed-off-by: Randy Dunlap <[email protected]> Reported-by: Igor Zhbanov <[email protected]> Link: lore.kernel.org/r/[email protected] Cc: Borislav Petkov <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Petr Mladek <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: John Ogness <[email protected]> Reviewed-by: John Ogness <[email protected]> Reviewed-by: Sergey Senozhatsky <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8484291 commit b665eae

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/printk/printk.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@ static int __control_devkmsg(char *str)
146146

147147
static int __init control_devkmsg(char *str)
148148
{
149-
if (__control_devkmsg(str) < 0)
149+
if (__control_devkmsg(str) < 0) {
150+
pr_warn("printk.devkmsg: bad option string '%s'\n", str);
150151
return 1;
152+
}
151153

152154
/*
153155
* Set sysctl string accordingly:
@@ -166,7 +168,7 @@ static int __init control_devkmsg(char *str)
166168
*/
167169
devkmsg_log |= DEVKMSG_LOG_MASK_LOCK;
168170

169-
return 0;
171+
return 1;
170172
}
171173
__setup("printk.devkmsg=", control_devkmsg);
172174

0 commit comments

Comments
 (0)