]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
proc: sysctl: prevent aliased sysctls from getting passed to init
authorKrister Johansen <kjlx@templeofstupid.com>
Fri, 27 Oct 2023 21:46:40 +0000 (14:46 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2023 17:15:00 +0000 (17:15 +0000)
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@templeofstupid.com>
Cc: stable@vger.kernel.org
Fixes: 0a477e1ae21b ("kernel/sysctl: support handling command line aliases")
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/proc/proc_sysctl.c
include/linux/sysctl.h
init/main.c

index 5ea42653126ebb40e7e8281a4acd76f01e690aab..d2ee02a3145e2e9f4df4358c5afa8ceed77b8eb2 100644 (file)
@@ -1590,6 +1590,13 @@ static const char *sysctl_find_alias(char *param)
        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)
index 59d451f455bfb78cf3f37fcb3ac65ecc2f6c18ce..094e5eaef072d48fb006ca2a302a3c4b6fcd89ae 100644 (file)
@@ -227,6 +227,7 @@ extern void __register_sysctl_init(const char *path, struct ctl_table *table,
 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(struct ctl_table_set *p,
 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,
index ad920fac325c367d813f7e9a552deb89b7e0a933..1e19a40f40c5f9ccb797b9bcbc60562b9c01fe4f 100644 (file)
@@ -530,6 +530,10 @@ static int __init unknown_bootoption(char *param, char *val,
 {
        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 */