From df19628b2b6665468e698e290dfd1568720ba042 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Thu, 28 Mar 2024 09:40:50 +0300 Subject: elf-load: Respect PT_GNU_STACK If a bootstrap ELF contains a PT_GNU_STACK phdr, take stack protection from there. Otherwise, default to VM_PROT_ALL. --- include/mach/exec/elf.h | 1 + include/mach/exec/exec.h | 2 ++ 2 files changed, 3 insertions(+) (limited to 'include') diff --git a/include/mach/exec/elf.h b/include/mach/exec/elf.h index 9e4f8f7e..55304496 100644 --- a/include/mach/exec/elf.h +++ b/include/mach/exec/elf.h @@ -300,6 +300,7 @@ typedef struct { #define PT_NOTE 4 #define PT_SHLIB 5 #define PT_PHDR 6 +#define PT_GNU_STACK 0x6474e551 #define PT_LOPROC 0x70000000 #define PT_HIPROC 0x7fffffff diff --git a/include/mach/exec/exec.h b/include/mach/exec/exec.h index 94b234b0..29fa897d 100644 --- a/include/mach/exec/exec.h +++ b/include/mach/exec/exec.h @@ -51,6 +51,8 @@ typedef struct exec_info /* (ELF) Address of interpreter string for loading shared libraries, null if none. */ vm_offset_t interp; + /* Required stack protection. */ + vm_prot_t stack_prot; } exec_info_t; typedef int exec_sectype_t; -- cgit v1.2.3