This is a note to let you know that I've just added the patch titled proc: sysctl: prevent aliased sysctls from getting passed to init to the 6.5-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: proc-sysctl-prevent-aliased-sysctls-from-getting-passed-to-init.patch and it can be found in the queue-6.5 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 8001f49394e353f035306a45bcf504f06fca6355 Mon Sep 17 00:00:00 2001 From: Krister Johansen <kjlx@xxxxxxxxxxxxxxxxxx> Date: Fri, 27 Oct 2023 14:46:40 -0700 Subject: proc: sysctl: prevent aliased sysctls from getting passed to init From: Krister Johansen <kjlx@xxxxxxxxxxxxxxxxxx> commit 8001f49394e353f035306a45bcf504f06fca6355 upstream. The code that checks for unknown boot options is unaware of the sysctl alias facility, which maps bootparams to sysctl values. If a user sets an old value that has a valid alias, a message about an invalid parameter will be printed during boot, and the parameter will get passed to init. Fix by checking for the existence of aliased parameters in the unknown boot parameter code. If an alias exists, don't return an error or pass the value to init. Signed-off-by: Krister Johansen <kjlx@xxxxxxxxxxxxxxxxxx> Cc: stable@xxxxxxxxxxxxxxx Fixes: 0a477e1ae21b ("kernel/sysctl: support handling command line aliases") Signed-off-by: Luis Chamberlain <mcgrof@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/proc/proc_sysctl.c | 7 +++++++ include/linux/sysctl.h | 6 ++++++ init/main.c | 4 ++++ 3 files changed, 17 insertions(+) --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -1590,6 +1590,13 @@ static const char *sysctl_find_alias(cha return NULL; } +bool sysctl_is_alias(char *param) +{ + const char *alias = sysctl_find_alias(param); + + return alias != NULL; +} + /* Set sysctl value passed on kernel command line. */ static int process_sysctl_arg(char *param, char *val, const char *unused, void *arg) --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -227,6 +227,7 @@ extern void __register_sysctl_init(const extern struct ctl_table_header *register_sysctl_mount_point(const char *path); void do_sysctl_args(void); +bool sysctl_is_alias(char *param); int do_proc_douintvec(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos, int (*conv)(unsigned long *lvalp, @@ -270,6 +271,11 @@ static inline void setup_sysctl_set(stru static inline void do_sysctl_args(void) { } + +static inline bool sysctl_is_alias(char *param) +{ + return false; +} #endif /* CONFIG_SYSCTL */ int sysctl_max_threads(struct ctl_table *table, int write, void *buffer, --- a/init/main.c +++ b/init/main.c @@ -530,6 +530,10 @@ static int __init unknown_bootoption(cha { size_t len = strlen(param); + /* Handle params aliased to sysctls */ + if (sysctl_is_alias(param)) + return 0; + repair_env_string(param, val); /* Handle obsolete-style parameters */ Patches currently in stable-queue which might be from kjlx@xxxxxxxxxxxxxxxxxx are queue-6.5/proc-sysctl-prevent-aliased-sysctls-from-getting-passed-to-init.patch