aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/mips
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-11-28 14:36:43 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-12-31 09:04:20 -0300
commit0ca8785a28515291d4ef074b5b6cfb27434c1d2b (patch)
treeba0b23b8b1bcef4d2717f1d605d32ef11518430c /sysdeps/unix/sysv/linux/mips
parentca96ea06b37c8601dcc9579dd4c8619322ab1ea1 (diff)
downloadglibc-0ca8785a28515291d4ef074b5b6cfb27434c1d2b.zip
glibc-0ca8785a28515291d4ef074b5b6cfb27434c1d2b.tar.gz
glibc-0ca8785a28515291d4ef074b5b6cfb27434c1d2b.tar.bz2
elf: Do not change stack permission on dlopen/dlmopen
If some shared library loaded with dlopen/dlmopen requires an executable stack, either implicitly because of a missing GNU_STACK ELF header (where the ABI default flags implies in the executable bit) or explicitly because of the executable bit from GNU_STACK; the loader will try to set the both the main thread and all thread stacks (from the pthread cache) as executable. Besides the issue where any __nptl_change_stack_perm failure does not undo the previous executable transition (meaning that if the library fails to load, there can be thread stacks with executable stacks), this behavior was used on a CVE [1] as a vector for RCE. This patch changes that if a shared library requires an executable stack, and the current stack is not executable, dlopen fails. The change is done only for dynamically loaded modules, if the program or any dependency requires an executable stack, the loader will still change the main thread before program execution and any thread created with default stack configuration. [1] https://www.qualys.com/2023/07/19/cve-2023-38408/rce-openssh-forwarded-ssh-agent.txt Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
Diffstat (limited to 'sysdeps/unix/sysv/linux/mips')
-rw-r--r--sysdeps/unix/sysv/linux/mips/Makefile7
1 files changed, 7 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/mips/Makefile b/sysdeps/unix/sysv/linux/mips/Makefile
index d5725c6..05ec915 100644
--- a/sysdeps/unix/sysv/linux/mips/Makefile
+++ b/sysdeps/unix/sysv/linux/mips/Makefile
@@ -61,6 +61,7 @@ ifeq ($(subdir),elf)
# this test is expected to fail.
ifneq ($(mips-has-gnustack),yes)
test-xfail-check-execstack = yes
+CFLAGS-tst-execstack.c += -DDEFAULT_RWX_STACK=1
endif
endif
@@ -68,6 +69,12 @@ ifeq ($(subdir),stdlib)
gen-as-const-headers += ucontext_i.sym
endif
+ifeq ($(subdir),nptl)
+ifeq ($(mips-force-execstack),yes)
+CFLAGS-tst-execstack-threads.c += -DDEFAULT_RWX_STACK=1
+endif
+endif
+
ifeq ($(mips-force-execstack),yes)
CFLAGS-.o += -Wa,-execstack
CFLAGS-.os += -Wa,-execstack