浏览代码

HBSD: Don't allow the RTLD to create an executable stack

Exploit authors love executable stacks.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
(cherry picked from commit eadfc6c84f)
Signed-off-by: Shawn Webb <shawn.webb@hardenedbsd.org>
remotes/github/hardened/12-stable/master
Shawn Webb 3 个月前
父节点
当前提交
253b686933
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. +11
    -0
      libexec/rtld-elf/rtld.c

+ 11
- 0
libexec/rtld-elf/rtld.c 查看文件

@@ -2169,12 +2169,23 @@ parse_rtld_phdr(Obj_Entry *obj)
const Elf_Phdr *ph;
Elf_Addr note_start, note_end;

#ifdef HARDENEDBSD
obj->stack_flags = PF_R | PF_W;
#else
obj->stack_flags = PF_X | PF_R | PF_W;
#endif
for (ph = obj->phdr; (const char *)ph < (const char *)obj->phdr +
obj->phsize; ph++) {
switch (ph->p_type) {
case PT_GNU_STACK:
obj->stack_flags = ph->p_flags;
#ifdef HARDENEDBSD
/*
* XXX Shared objects that set RWX stack can
* die in a fire
*/
obj->stack_flags &= ~(PF_X);
#endif
break;
case PT_GNU_RELRO:
obj->relro_page = obj->relocbase +


正在加载...
取消
保存