From b069d3e0193121ff6de348f68c7ce93ee61e5e2f Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Wed, 4 Jan 2023 14:55:00 -0800 Subject: [PATCH] rtld: Revert "When loading dso without PT_GNU_STACK phdr, only call" After the removal of ia64 and sparc64, all current architectures support executable stacks at an architectural level. This reverts commit 1290d38ac50b3afa7e5781d9d97346a1042c736c. Reviewed by: kib Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D37904 --- libexec/rtld-elf/aarch64/rtld_machdep.h | 3 --- libexec/rtld-elf/amd64/rtld_machdep.h | 3 --- libexec/rtld-elf/arm/rtld_machdep.h | 3 --- libexec/rtld-elf/i386/rtld_machdep.h | 3 --- libexec/rtld-elf/map_object.c | 2 +- libexec/rtld-elf/powerpc/rtld_machdep.h | 3 --- libexec/rtld-elf/powerpc64/rtld_machdep.h | 3 --- libexec/rtld-elf/riscv/rtld_machdep.h | 3 --- libexec/rtld-elf/rtld.c | 2 +- 9 files changed, 2 insertions(+), 23 deletions(-) diff --git a/libexec/rtld-elf/aarch64/rtld_machdep.h b/libexec/rtld-elf/aarch64/rtld_machdep.h index ce6f6fc6c7c0..8fed482340b7 100644 --- a/libexec/rtld-elf/aarch64/rtld_machdep.h +++ b/libexec/rtld-elf/aarch64/rtld_machdep.h @@ -87,9 +87,6 @@ typedef struct { extern void *__tls_get_addr(tls_index *ti); -#define RTLD_DEFAULT_STACK_PF_EXEC PF_X -#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC - #define md_abi_variant_hook(x) #endif diff --git a/libexec/rtld-elf/amd64/rtld_machdep.h b/libexec/rtld-elf/amd64/rtld_machdep.h index 99f020e60221..e37301b8174a 100644 --- a/libexec/rtld-elf/amd64/rtld_machdep.h +++ b/libexec/rtld-elf/amd64/rtld_machdep.h @@ -69,9 +69,6 @@ typedef struct { void *__tls_get_addr(tls_index *ti) __exported; -#define RTLD_DEFAULT_STACK_PF_EXEC PF_X -#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC - #define md_abi_variant_hook(x) size_t calculate_first_tls_offset(size_t size, size_t align, size_t offset); diff --git a/libexec/rtld-elf/arm/rtld_machdep.h b/libexec/rtld-elf/arm/rtld_machdep.h index c1acdd719e99..e4d68c360363 100644 --- a/libexec/rtld-elf/arm/rtld_machdep.h +++ b/libexec/rtld-elf/arm/rtld_machdep.h @@ -73,9 +73,6 @@ typedef struct { extern void *__tls_get_addr(tls_index *ti); -#define RTLD_DEFAULT_STACK_PF_EXEC PF_X -#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC - #define md_abi_variant_hook(x) #endif diff --git a/libexec/rtld-elf/i386/rtld_machdep.h b/libexec/rtld-elf/i386/rtld_machdep.h index ee41e31bd591..9d62bc26eb5b 100644 --- a/libexec/rtld-elf/i386/rtld_machdep.h +++ b/libexec/rtld-elf/i386/rtld_machdep.h @@ -70,9 +70,6 @@ typedef struct { void *___tls_get_addr(tls_index *ti) __attribute__((__regparm__(1))) __exported; void *__tls_get_addr(tls_index *ti) __exported; -#define RTLD_DEFAULT_STACK_PF_EXEC PF_X -#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC - #define md_abi_variant_hook(x) size_t calculate_first_tls_offset(size_t size, size_t align, size_t offset); diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c index 7c637fe1d6ba..4bf32398710d 100644 --- a/libexec/rtld-elf/map_object.c +++ b/libexec/rtld-elf/map_object.c @@ -122,7 +122,7 @@ map_object(int fd, const char *path, const struct stat *sb) note_map = NULL; note_map_len = 0; segs = alloca(sizeof(segs[0]) * hdr->e_phnum); - stack_flags = RTLD_DEFAULT_STACK_PF_EXEC | PF_R | PF_W; + stack_flags = PF_X | PF_R | PF_W; text_end = 0; while (phdr < phlimit) { switch (phdr->p_type) { diff --git a/libexec/rtld-elf/powerpc/rtld_machdep.h b/libexec/rtld-elf/powerpc/rtld_machdep.h index b3e2e3fafa9f..44298ec2a127 100644 --- a/libexec/rtld-elf/powerpc/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc/rtld_machdep.h @@ -89,9 +89,6 @@ typedef struct { extern void *__tls_get_addr(tls_index* ti); -#define RTLD_DEFAULT_STACK_PF_EXEC PF_X -#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC - extern void powerpc_abi_variant_hook(Elf_Auxinfo **); #define md_abi_variant_hook(x) powerpc_abi_variant_hook(x) diff --git a/libexec/rtld-elf/powerpc64/rtld_machdep.h b/libexec/rtld-elf/powerpc64/rtld_machdep.h index c8dcebe45ae2..67c4810da93b 100644 --- a/libexec/rtld-elf/powerpc64/rtld_machdep.h +++ b/libexec/rtld-elf/powerpc64/rtld_machdep.h @@ -81,9 +81,6 @@ typedef struct { extern void *__tls_get_addr(tls_index* ti); -#define RTLD_DEFAULT_STACK_PF_EXEC PF_X -#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC - extern void powerpc64_abi_variant_hook(Elf_Auxinfo **); #define md_abi_variant_hook(x) powerpc64_abi_variant_hook(x) diff --git a/libexec/rtld-elf/riscv/rtld_machdep.h b/libexec/rtld-elf/riscv/rtld_machdep.h index e422905f3850..2421b2f4108b 100644 --- a/libexec/rtld-elf/riscv/rtld_machdep.h +++ b/libexec/rtld-elf/riscv/rtld_machdep.h @@ -99,9 +99,6 @@ typedef struct { extern void *__tls_get_addr(tls_index* ti); -#define RTLD_DEFAULT_STACK_PF_EXEC PF_X -#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC - #define md_abi_variant_hook(x) #endif diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 2a142d333740..7e4df3392ec7 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -269,7 +269,7 @@ static int osreldate; size_t *pagesizes; size_t page_size; -static int stack_prot = PROT_READ | PROT_WRITE | RTLD_DEFAULT_STACK_EXEC; +static int stack_prot = PROT_READ | PROT_WRITE | PROT_EXEC; static int max_stack_flags; /*