]> git.ipfire.org Git - thirdparty/glibc.git/commit
elf: Extend glibc.rtld.execstack tunable to force executable stack (BZ 32653)
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 13 Feb 2025 17:02:38 +0000 (14:02 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 9 Apr 2025 13:19:36 +0000 (13:19 +0000)
commitb861755a84eeccdd9183989ca71b3b1251c83a74
treee7e19c3c5e90fa258e313d4bec71ff144812f3e7
parent200d20123cb8ee15ad5d15c9a4adcd2999acb9f1
elf: Extend glibc.rtld.execstack tunable to force executable stack (BZ 32653)

From the bug report [1], multiple programs still require to dlopen
shared libraries with either missing PT_GNU_STACK or with the executable
bit set.  Although, in some cases, it seems to be a hard-craft assembly
source without the required .note.GNU-stack marking (so the static linker
is forced to set the stack executable if the ABI requires it), other
cases seem that the library uses trampolines [2].

Unfortunately, READ_IMPLIES_EXEC is not an option since on some ABIs
(x86_64), the kernel clears the bit, making it unsupported.  To avoid
reinstating the broken code that changes stack permission on dlopen
(0ca8785a28), this patch extends the glibc.rtld.execstack tunable to
allow an option to force an executable stack at the program startup.

The tunable is a security issue because it defeats the PT_GNU_STACK
hardening.  It has the slight advantage of making it explicit by the
caller, and, as for other tunables, this is disabled for setuid binaries.
A tunable also allows us to eventually remove it, but from previous
experiences, it would require some time.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=32653
[2] https://github.com/conda-forge/ctng-compiler-activation-feedstock/issues/143
Reviewed-by: Sam James <sam@gentoo.org>
(cherry picked from commit 12a497c716f0a06be5946cabb8c3ec22a079771e)
NEWS
elf/Makefile
elf/dl-execstack-tunable.c [new file with mode: 0644]
elf/dl-support.c
elf/dl-tunables.list
elf/rtld.c
elf/tst-execstack-prog-static-tunable.c [new file with mode: 0644]
elf/tst-execstack-tunable.c [new file with mode: 0644]
elf/tst-rtld-list-tunables.exp
manual/tunables.texi
sysdeps/generic/ldsodefs.h