aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-06-11 12:27:04 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-06-12 15:25:54 -0300
commit7edd3814b00c46a404cbaf316eab9db18438c3dd (patch)
tree5c5c9eeb8b9f2ab01c182b95ba8fef906499d304 /sysdeps/unix/sysv
parente7ac92e6ca9784b397189df0b2e1fb34f425bab8 (diff)
downloadglibc-7edd3814b00c46a404cbaf316eab9db18438c3dd.zip
glibc-7edd3814b00c46a404cbaf316eab9db18438c3dd.tar.gz
glibc-7edd3814b00c46a404cbaf316eab9db18438c3dd.tar.bz2
linux: Remove __stack_prot
The __stack_prot is used by Linux to make the stack executable if a modules requires it. It is also marked as RELRO, which requires to change the segment permission to RW to update it. Also, there is no need to keep track of the flags: either the stack will have the default permission of the ABI or should be change to PROT_READ | PROT_WRITE | PROT_EXEC. The only additional flag, PROT_GROWSDOWN or PROT_GROWSUP, is Linux only and can be deducted from _STACK_GROWS_DOWN/_STACK_GROWS_UP. Also, the check_consistency function was already removed some time ago. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r--sysdeps/unix/sysv/linux/dl-execstack.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/sysdeps/unix/sysv/linux/dl-execstack.c b/sysdeps/unix/sysv/linux/dl-execstack.c
index 3d8f3938..b986898 100644
--- a/sysdeps/unix/sysv/linux/dl-execstack.c
+++ b/sysdeps/unix/sysv/linux/dl-execstack.c
@@ -27,35 +27,30 @@
#include <sysdep.h>
#include <unistd.h>
-extern int __stack_prot attribute_relro attribute_hidden;
-
static int
make_main_stack_executable (void **stack_endp)
{
/* This gives us the highest/lowest page that needs to be changed. */
uintptr_t page = ((uintptr_t) *stack_endp
& -(intptr_t) GLRO(dl_pagesize));
- int result = 0;
- if (__builtin_expect (__mprotect ((void *) page, GLRO(dl_pagesize),
- __stack_prot) == 0, 1))
- goto return_success;
- result = errno;
- goto out;
+ if (__mprotect ((void *) page, GLRO(dl_pagesize),
+ PROT_READ | PROT_WRITE | PROT_EXEC
+#if _STACK_GROWS_DOWN
+ | PROT_GROWSDOWN
+#elif _STACK_GROWS_UP
+ | PROT_GROWSUP
+#endif
+ ) != 0)
+ return errno;
- return_success:
/* Clear the address. */
*stack_endp = NULL;
/* Remember that we changed the permission. */
GL(dl_stack_flags) |= PF_X;
- out:
-#ifdef check_consistency
- check_consistency ();
-#endif
-
- return result;
+ return 0;
}
int