Skip to content

Commit b121dd4

Browse files
yukaixiongJoelgranados
authored andcommitted
security: min_addr: move sysctl to security/min_addr.c
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]>
1 parent aacdde7 commit b121dd4

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

kernel/sysctl.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,15 +2049,6 @@ static const struct ctl_table vm_table[] = {
20492049
.proc_handler = proc_dointvec_minmax,
20502050
.extra1 = SYSCTL_ZERO,
20512051
},
2052-
#ifdef CONFIG_MMU
2053-
{
2054-
.procname = "mmap_min_addr",
2055-
.data = &dac_mmap_min_addr,
2056-
.maxlen = sizeof(unsigned long),
2057-
.mode = 0644,
2058-
.proc_handler = mmap_min_addr_handler,
2059-
},
2060-
#endif
20612052
#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
20622053
(defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
20632054
{

security/min_addr.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,19 @@ int mmap_min_addr_handler(const struct ctl_table *table, int write,
4444
return ret;
4545
}
4646

47+
static const struct ctl_table min_addr_sysctl_table[] = {
48+
{
49+
.procname = "mmap_min_addr",
50+
.data = &dac_mmap_min_addr,
51+
.maxlen = sizeof(unsigned long),
52+
.mode = 0644,
53+
.proc_handler = mmap_min_addr_handler,
54+
},
55+
};
56+
4757
static int __init init_mmap_min_addr(void)
4858
{
59+
register_sysctl_init("vm", min_addr_sysctl_table);
4960
update_mmap_min_addr();
5061

5162
return 0;

0 commit comments

Comments
 (0)