Skip to content
Snippets Groups Projects
Commit 783a58ce authored by Krister Johansen's avatar Krister Johansen Committed by Frieder Schrempf
Browse files

proc: sysctl: prevent aliased sysctls from getting passed to init


commit 8001f493 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: default avatarKrister Johansen <kjlx@templeofstupid.com>
Cc: stable@vger.kernel.org
Fixes: 0a477e1a ("kernel/sysctl: support handling command line aliases")
Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6b0ce09e
No related branches found
No related tags found
1 merge request!119🤖 Sync Bot: Update v6.1-ktn to Latest Stable Kernel (v6.1.66)
...@@ -1830,6 +1830,13 @@ static const char *sysctl_find_alias(char *param) ...@@ -1830,6 +1830,13 @@ static const char *sysctl_find_alias(char *param)
return NULL; 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. */ /* Set sysctl value passed on kernel command line. */
static int process_sysctl_arg(char *param, char *val, static int process_sysctl_arg(char *param, char *val,
const char *unused, void *arg) const char *unused, void *arg)
......
...@@ -238,6 +238,7 @@ extern void __register_sysctl_init(const char *path, struct ctl_table *table, ...@@ -238,6 +238,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); extern struct ctl_table_header *register_sysctl_mount_point(const char *path);
void do_sysctl_args(void); void do_sysctl_args(void);
bool sysctl_is_alias(char *param);
int do_proc_douintvec(struct ctl_table *table, int write, int do_proc_douintvec(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos, void *buffer, size_t *lenp, loff_t *ppos,
int (*conv)(unsigned long *lvalp, int (*conv)(unsigned long *lvalp,
...@@ -301,6 +302,11 @@ static inline void setup_sysctl_set(struct ctl_table_set *p, ...@@ -301,6 +302,11 @@ static inline void setup_sysctl_set(struct ctl_table_set *p,
static inline void do_sysctl_args(void) static inline void do_sysctl_args(void)
{ {
} }
static inline bool sysctl_is_alias(char *param)
{
return false;
}
#endif /* CONFIG_SYSCTL */ #endif /* CONFIG_SYSCTL */
int sysctl_max_threads(struct ctl_table *table, int write, void *buffer, int sysctl_max_threads(struct ctl_table *table, int write, void *buffer,
......
...@@ -533,6 +533,10 @@ static int __init unknown_bootoption(char *param, char *val, ...@@ -533,6 +533,10 @@ static int __init unknown_bootoption(char *param, char *val,
{ {
size_t len = strlen(param); size_t len = strlen(param);
/* Handle params aliased to sysctls */
if (sysctl_is_alias(param))
return 0;
repair_env_string(param, val); repair_env_string(param, val);
/* Handle obsolete-style parameters */ /* Handle obsolete-style parameters */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment