]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
security: min_addr: move sysctl to security/min_addr.c
authorKaixiong Yu <yukaixiong@huawei.com>
Sat, 11 Jan 2025 07:07:42 +0000 (15:07 +0800)
committerJoel Granados <joel.granados@kernel.org>
Fri, 7 Feb 2025 15:53:04 +0000 (16:53 +0100)
The dac_mmap_min_addr belongs to min_addr.c, move it to
min_addr.c from /kernel/sysctl.c. In the previous Linux kernel
boot process, sysctl_init_bases needs to be executed before
init_mmap_min_addr, So, register_sysctl_init should be executed
before update_mmap_min_addr in init_mmap_min_addr. And according
to the compilation condition in security/Makefile:

      obj-$(CONFIG_MMU)            += min_addr.o

if CONFIG_MMU is not defined, min_addr.c would not be included in the
compilation process. So, drop the CONFIG_MMU check.

Signed-off-by: Kaixiong Yu <yukaixiong@huawei.com>
Reviewed-by: Kees Cook <kees@kernel.org>
Acked-by: Paul Moore <paul@paul-moore.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Joel Granados <joel.granados@kernel.org>
kernel/sysctl.c
security/min_addr.c

index 98a95396d20b7aea9712c2df31c7ad963e450040..c9e91ea550d7cefcfe75146ebd4e807065adc766 100644 (file)
@@ -2049,15 +2049,6 @@ static const struct ctl_table vm_table[] = {
                .proc_handler   = proc_dointvec_minmax,
                .extra1         = SYSCTL_ZERO,
        },
-#ifdef CONFIG_MMU
-       {
-               .procname       = "mmap_min_addr",
-               .data           = &dac_mmap_min_addr,
-               .maxlen         = sizeof(unsigned long),
-               .mode           = 0644,
-               .proc_handler   = mmap_min_addr_handler,
-       },
-#endif
 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
        {
index 0ce267c041ab2c120703a660896c54b7be1e1dbd..df1bc643d886bd746953e4175e10e1de6f4f1ca0 100644 (file)
@@ -44,8 +44,19 @@ int mmap_min_addr_handler(const struct ctl_table *table, int write,
        return ret;
 }
 
+static const struct ctl_table min_addr_sysctl_table[] = {
+       {
+               .procname       = "mmap_min_addr",
+               .data           = &dac_mmap_min_addr,
+               .maxlen         = sizeof(unsigned long),
+               .mode           = 0644,
+               .proc_handler   = mmap_min_addr_handler,
+       },
+};
+
 static int __init init_mmap_min_addr(void)
 {
+       register_sysctl_init("vm", min_addr_sysctl_table);
        update_mmap_min_addr();
 
        return 0;