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:07:08 +0000 (17:07 +0000)
commit5b2352c64c4829fc4fc039182fb182a013cb61b2
treef5ce410c72d1fc3d3afc899682c39cedd9ee64b3
parentd91fd028c9f6acfec3094c0989a59c29c87d3b71
proc: sysctl: prevent aliased sysctls from getting passed to init

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