Skip to content

Commit 2b1ee51

Browse files
kmjohansengregkh
authored andcommitted
proc: sysctl: prevent aliased sysctls from getting passed to init
commit 8001f49 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: 0a477e1 ("kernel/sysctl: support handling command line aliases") Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d567eb7 commit 2b1ee51

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

fs/proc/proc_sysctl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,13 @@ static const char *sysctl_find_alias(char *param)
15921592
return NULL;
15931593
}
15941594

1595+
bool sysctl_is_alias(char *param)
1596+
{
1597+
const char *alias = sysctl_find_alias(param);
1598+
1599+
return alias != NULL;
1600+
}
1601+
15951602
/* Set sysctl value passed on kernel command line. */
15961603
static int process_sysctl_arg(char *param, char *val,
15971604
const char *unused, void *arg)

include/linux/sysctl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ extern void __register_sysctl_init(const char *path, struct ctl_table *table,
242242
extern struct ctl_table_header *register_sysctl_mount_point(const char *path);
243243

244244
void do_sysctl_args(void);
245+
bool sysctl_is_alias(char *param);
245246
int do_proc_douintvec(struct ctl_table *table, int write,
246247
void *buffer, size_t *lenp, loff_t *ppos,
247248
int (*conv)(unsigned long *lvalp,
@@ -287,6 +288,11 @@ static inline void setup_sysctl_set(struct ctl_table_set *p,
287288
static inline void do_sysctl_args(void)
288289
{
289290
}
291+
292+
static inline bool sysctl_is_alias(char *param)
293+
{
294+
return false;
295+
}
290296
#endif /* CONFIG_SYSCTL */
291297

292298
int sysctl_max_threads(struct ctl_table *table, int write, void *buffer,

init/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,10 @@ static int __init unknown_bootoption(char *param, char *val,
530530
{
531531
size_t len = strlen(param);
532532

533+
/* Handle params aliased to sysctls */
534+
if (sysctl_is_alias(param))
535+
return 0;
536+
533537
repair_env_string(param, val);
534538

535539
/* Handle obsolete-style parameters */

0 commit comments

Comments
 (0)