提交 1efdacff 编写于 作者: L Liu Zixian 提交者: Zheng Zengkai

fs: add sysctl knob for exec_hugetlb

euleros inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I4X1VR
CVE: NA

------------
If we have a bug in this feature, users can disable exec_hugetlb
without changing application binaries.
Signed-off-by: NLiu Zixian <liuzixian4@huawei.com>
Reviewed-by: NZhou Kang <zhoukang7@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
上级 868f2795
...@@ -474,7 +474,7 @@ static unsigned long elf_map(struct file *filep, unsigned long addr, ...@@ -474,7 +474,7 @@ static unsigned long elf_map(struct file *filep, unsigned long addr,
return addr; return addr;
#ifdef CONFIG_EXEC_HUGETLB #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, return elf_hugetlb_map(filep, addr, eppnt, prot, type,
total_size); total_size);
#endif #endif
...@@ -1308,7 +1308,7 @@ static int load_elf_binary(struct linux_binprm *bprm) ...@@ -1308,7 +1308,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
* bss is allocated in elf_hugetlb_bss, * bss is allocated in elf_hugetlb_bss,
* so skip vm_brk_flags in set_brk * 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); elf_bss = elf_brk = ELF_HPAGEALIGN(elf_brk);
#endif #endif
} }
......
...@@ -74,6 +74,10 @@ ...@@ -74,6 +74,10 @@
#include <trace/events/sched.h> #include <trace/events/sched.h>
#ifdef CONFIG_EXEC_HUGETLB
int exec_hugetlb;
#endif
static int bprm_creds_from_file(struct linux_binprm *bprm); static int bprm_creds_from_file(struct linux_binprm *bprm);
int suid_dumpable = 0; int suid_dumpable = 0;
......
...@@ -99,4 +99,8 @@ static inline int arch_elf_adjust_prot(int prot, ...@@ -99,4 +99,8 @@ static inline int arch_elf_adjust_prot(int prot,
} }
#endif #endif
#ifdef CONFIG_EXEC_HUGETLB
extern int exec_hugetlb;
#endif
#endif /* _LINUX_ELF_H */ #endif /* _LINUX_ELF_H */
...@@ -3543,6 +3543,17 @@ static struct ctl_table fs_table[] = { ...@@ -3543,6 +3543,17 @@ static struct ctl_table fs_table[] = {
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ONE, .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
{ } { }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册