diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 01c45582a910d57230b198cc4130cb088a65e837..16abbd7f6fc2cb775578e0260572447d542faf85 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -474,7 +474,7 @@ static unsigned long elf_map(struct file *filep, unsigned long addr, return addr; #ifdef CONFIG_EXEC_HUGETLB - if (eppnt->p_flags & PF_HUGETLB) + if (exec_hugetlb && (eppnt->p_flags & PF_HUGETLB)) return elf_hugetlb_map(filep, addr, eppnt, prot, type, total_size); #endif @@ -1308,7 +1308,7 @@ static int load_elf_binary(struct linux_binprm *bprm) * bss is allocated in elf_hugetlb_bss, * so skip vm_brk_flags in set_brk */ - if (elf_ppnt->p_flags & PF_HUGETLB) + if (exec_hugetlb && (elf_ppnt->p_flags & PF_HUGETLB)) elf_bss = elf_brk = ELF_HPAGEALIGN(elf_brk); #endif } diff --git a/fs/exec.c b/fs/exec.c index 4c2d18061633247d926e80b4176135c77145b23f..cf2077bffc0a019085a875297fb7cd55c8d40864 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -74,6 +74,10 @@ #include +#ifdef CONFIG_EXEC_HUGETLB +int exec_hugetlb; +#endif + static int bprm_creds_from_file(struct linux_binprm *bprm); int suid_dumpable = 0; diff --git a/include/linux/elf.h b/include/linux/elf.h index 5d5b0321da0bd81db3afa2bbe802252ca7e58a94..3e64eab033843932c613ed8e287f4c04301871e8 100644 --- a/include/linux/elf.h +++ b/include/linux/elf.h @@ -99,4 +99,8 @@ static inline int arch_elf_adjust_prot(int prot, } #endif +#ifdef CONFIG_EXEC_HUGETLB +extern int exec_hugetlb; +#endif + #endif /* _LINUX_ELF_H */ diff --git a/kernel/sysctl.c b/kernel/sysctl.c index d1243d1150b25790feb3ac718d62b7a00e77c2c9..a0df602c93729c40ce7b4160b3796ba1bb8d86a5 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -3543,6 +3543,17 @@ static struct ctl_table fs_table[] = { .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ONE, }, +#ifdef CONFIG_EXEC_HUGETLB + { + .procname = "exec-use-hugetlb", + .data = &exec_hugetlb, + .maxlen = sizeof(exec_hugetlb), + .mode = 0600, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, +#endif { } };