]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mm: move randomize_va_space into memory.c
authorJoel Granados <joel.granados@kernel.org>
Wed, 30 Apr 2025 12:42:13 +0000 (14:42 +0200)
committerJoel Granados <joel.granados@kernel.org>
Wed, 23 Jul 2025 09:52:47 +0000 (11:52 +0200)
Move the randomize_va_space variable together with all its sysctl table
elements into memory.c. Register it to the "kernel" directory by
adding it to the subsys initialization calls

This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kernel/sysctl.c.

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Joel Granados <joel.granados@kernel.org>
kernel/sysctl.c
mm/memory.c

index fd76f0e1d490940a67d72403d72d204ff13d888a..adc2d3ea127841d87b7073ed81d6121c9a60e59a 100644 (file)
@@ -1688,15 +1688,6 @@ static const struct ctl_table kern_table[] = {
                .proc_handler   = proc_dointvec,
        },
 #endif
-#if defined(CONFIG_MMU)
-       {
-               .procname       = "randomize_va_space",
-               .data           = &randomize_va_space,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = proc_dointvec,
-       },
-#endif
 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
        {
                .procname       = "ignore-unaligned-usertrap",
index 8eba595056fe3f131fbc1f1f06698fda9395a99f..f9e334fb9166e24c18ee0307e4f4dfca5505f277 100644 (file)
@@ -125,6 +125,24 @@ int randomize_va_space __read_mostly =
                                        2;
 #endif
 
+static const struct ctl_table mmu_sysctl_table[] = {
+       {
+               .procname       = "randomize_va_space",
+               .data           = &randomize_va_space,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec,
+       },
+};
+
+static int __init init_mm_sysctl(void)
+{
+       register_sysctl_init("kernel", mmu_sysctl_table);
+       return 0;
+}
+
+subsys_initcall(init_mm_sysctl);
+
 #ifndef arch_wants_old_prefaulted_pte
 static inline bool arch_wants_old_prefaulted_pte(void)
 {