Skip to content

Commit

Permalink
security: min_addr: move sysctl to security/min_addr.c
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Acked-by: Paul Moore <[email protected]>
Reviewed-by: Jeff Layton <[email protected]>
Signed-off-by: Joel Granados <[email protected]>
  • Loading branch information
Kaixiong Yu authored and Joelgranados committed Feb 7, 2025
1 parent aacdde7 commit b121dd4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 0 additions & 9 deletions kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
11 changes: 11 additions & 0 deletions security/min_addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b121dd4

Please sign in to comment.