printk: fix return value of printk.devkmsg __setup handler
PATCH 1/1 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.
--- kernel/printk/printk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/printk/printk.c +4 -2
@@ -152,8 +152,10 @@ static int __control_devkmsg(char *str)static int __init control_devkmsg (char *str) { -if (__control_devkmsg (str) <0 ) +if (__control_devkmsg (str) <0 ) { +pr_warn ("printk.devkmsg: bad option string '%s'\n" , str);return 1 ; + }/* * Set sysctl string accordingly:
@@ -172,7 +174,7 @@ static int __init control_devkmsg(char **/ devkmsg_log |=DEVKMSG_LOG_MASK_LOCK ; -return 0 ; +return 1 ; }__setup ("printk.devkmsg=" , control_devkmsg);
Quoted 9 lines · Randy Dunlap
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".
Quoted 7 lines
Print a warning message if a bad option string is used. Always return 1 from the
__setuphandler to indicate that the command line option has been handled.Fixes 750afe7babd1 ("printk: add kernel parameter to control writes to /dev/kmsg")Signed-off-by Randy Dunlap <[email protected]>Reported-by Igor Zhbanov <[email protected]>
Quoted 1 line
Link lore.kernel.org/r/[email protected]
The message at this link is very helpful in explaining the state of declaring kernel parameters. Hopefully someday someone will document and/or comment this stuff.
John Ogness
Quoted 18 lines · John Ogness
Quoted 9 lines · Randy Dunlap
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".Quoted 7 lines
Print a warning message if a bad option string is used. Always return 1 from the
__setuphandler to indicate that the command line option has been handled.Fixes 750afe7babd1 ("printk: add kernel parameter to control writes to /dev/kmsg")Signed-off-by Randy Dunlap <[email protected]>Reported-by Igor Zhbanov <[email protected]>
Quoted 7 lines
Reviewed-by John Ogness <[email protected]>Quoted 1 line
Link lore.kernel.org/r/[email protected]The message at this link is very helpful in explaining the state of declaring kernel parameters. Hopefully someday someone will document and/or comment this stuff.
I have added some docs to include/linux/init.h.
Andrew has it in his mmotm queue.
Signature · 1 line
~Randy
Quoted 9 lines · Randy Dunlap
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".
Quoted 8 lines
Print a warning message if a bad option string is used. Always return 1 from the
__setuphandler to indicate that the command line option has been handled.Fixes 750afe7babd1 ("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]
Good catch! I am learning something new every day :-)
Best Regards,
Petr
Quoted 13 lines · Randy Dunlap
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
__setuphandler to indicate that the command line option has been handled.
Quoted 10 lines
Fixes 750afe7babd1 ("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]>
Petr Mladek
maintainerQuoted 13 lines · Randy Dunlap
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
__setuphandler to indicate that the command line option has been handled.
Quoted 10 lines
Fixes 750afe7babd1 ("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]>
The patch has been committed into printk/linux.git, branch for-5.18.
Best Regards,
Petr