]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86: vdso: move the sysctl to arch/x86/entry/vdso/vdso32-setup.c
authorKaixiong Yu <yukaixiong@huawei.com>
Sat, 11 Jan 2025 07:07:48 +0000 (15:07 +0800)
committerJoel Granados <joel.granados@kernel.org>
Fri, 7 Feb 2025 15:53:04 +0000 (16:53 +0100)
When CONFIG_X86_32 is defined and CONFIG_UML is not defined,
vdso_enabled belongs to arch/x86/entry/vdso/vdso32-setup.c.
So, move it into its own file.

Before this patch, vdso_enabled was allowed to be set to
a value exceeding 1 on x86_32 architecture. After this patch is
applied, vdso_enabled is not permitted to set the value more than 1.
It does not matter, because according to the function load_vdso32(),
only vdso_enabled is set to 1, VDSO would be enabled. Other values
all mean "disabled". The same limitation could be seen in the
function vdso32_setup().

Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Joel Granados <joel.granados@kernel.org>
arch/x86/entry/vdso/vdso32-setup.c
kernel/sysctl.c

index f6d2d8aba6434a3053d9a53eb027ed74e14423e6..8894013eea1dac5587784151d92da0c7a2d6f107 100644 (file)
@@ -51,15 +51,17 @@ __setup("vdso32=", vdso32_setup);
 __setup_param("vdso=", vdso_setup, vdso32_setup, 0);
 #endif
 
-#ifdef CONFIG_X86_64
 
 #ifdef CONFIG_SYSCTL
-/* Register vsyscall32 into the ABI table */
 #include <linux/sysctl.h>
 
-static const struct ctl_table abi_table2[] = {
+static const struct ctl_table vdso_table[] = {
        {
+#ifdef CONFIG_X86_64
                .procname       = "vsyscall32",
+#else
+               .procname       = "vdso_enabled",
+#endif
                .data           = &vdso32_enabled,
                .maxlen         = sizeof(int),
                .mode           = 0644,
@@ -71,10 +73,14 @@ static const struct ctl_table abi_table2[] = {
 
 static __init int ia32_binfmt_init(void)
 {
-       register_sysctl("abi", abi_table2);
+#ifdef CONFIG_X86_64
+       /* Register vsyscall32 into the ABI table */
+       register_sysctl("abi", vdso_table);
+#else
+       register_sysctl_init("vm", vdso_table);
+#endif
        return 0;
 }
 __initcall(ia32_binfmt_init);
 #endif /* CONFIG_SYSCTL */
 
-#endif /* CONFIG_X86_64 */
index 7e345c7148a17d62125e8e95add69410e93d76fa..c4833a555bd2c8588e991f88134113c87afcb0d5 100644 (file)
@@ -2013,17 +2013,11 @@ static const struct ctl_table kern_table[] = {
 };
 
 static const struct ctl_table vm_table[] = {
-#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
-   (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
+#if defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)
        {
                .procname       = "vdso_enabled",
-#ifdef CONFIG_X86_32
-               .data           = &vdso32_enabled,
-               .maxlen         = sizeof(vdso32_enabled),
-#else
                .data           = &vdso_enabled,
                .maxlen         = sizeof(vdso_enabled),
-#endif
                .mode           = 0644,
                .proc_handler   = proc_dointvec,
                .extra1         = SYSCTL_ZERO,