Skip to content

Commit 851911a

Browse files
committed
mm: move randomize_va_space into memory.c
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 <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Joel Granados <[email protected]>
1 parent fff6703 commit 851911a

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

kernel/sysctl.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,15 +1688,6 @@ static const struct ctl_table kern_table[] = {
16881688
.proc_handler = proc_dointvec,
16891689
},
16901690
#endif
1691-
#if defined(CONFIG_MMU)
1692-
{
1693-
.procname = "randomize_va_space",
1694-
.data = &randomize_va_space,
1695-
.maxlen = sizeof(int),
1696-
.mode = 0644,
1697-
.proc_handler = proc_dointvec,
1698-
},
1699-
#endif
17001691
#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
17011692
{
17021693
.procname = "ignore-unaligned-usertrap",

mm/memory.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,24 @@ int randomize_va_space __read_mostly =
125125
2;
126126
#endif
127127

128+
static const struct ctl_table mmu_sysctl_table[] = {
129+
{
130+
.procname = "randomize_va_space",
131+
.data = &randomize_va_space,
132+
.maxlen = sizeof(int),
133+
.mode = 0644,
134+
.proc_handler = proc_dointvec,
135+
},
136+
};
137+
138+
static int __init init_mm_sysctl(void)
139+
{
140+
register_sysctl_init("kernel", mmu_sysctl_table);
141+
return 0;
142+
}
143+
144+
subsys_initcall(init_mm_sysctl);
145+
128146
#ifndef arch_wants_old_prefaulted_pte
129147
static inline bool arch_wants_old_prefaulted_pte(void)
130148
{

0 commit comments

Comments
 (0)