[PATCH 2/2] init/main.c: return 1 from handled __setup() functions

From: Randy Dunlap
Date: Mon Feb 21 2022 - 00:09:09 EST


initcall_blacklist() should return 1 to indicate that it handled its
cmdline arguments.

set_debug_rodata() should return 1 to indicate that it handled its
cmdline arguments. Print a warning if the option string is invalid.

This prevents these strings from being added to the 'init' program's
environment as they are not init arguments/parameters.

Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Reported-by: Igor Zhbanov <i.zhbanov@xxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
init/main.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

--- linux-next-20220217.orig/init/main.c
+++ linux-next-20220217/init/main.c
@@ -1195,7 +1195,7 @@ static int __init initcall_blacklist(cha
}
} while (str_entry);

- return 0;
+ return 1;
}

static bool __init_or_module initcall_blacklisted(initcall_t fn)
@@ -1455,7 +1455,9 @@ static noinline void __init kernel_init_
bool rodata_enabled __ro_after_init = true;
static int __init set_debug_rodata(char *str)
{
- return strtobool(str, &rodata_enabled);
+ if (strtobool(str, &rodata_enabled))
+ pr_warn("Invalid option string for rodata: '%s'\n", str);
+ return 1;
}
__setup("rodata=", set_debug_rodata);
#endif