[PATCH v4] elf: Extend glibc.rtld.execstack tunable to force executable stack (BZ 32653)
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Tue Apr 8 13:28:43 GMT 2025
On 20/03/25 17:01, Sam James wrote:
> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
>
>> 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.
>
> Thanks. I spent some more time looking at it and I'm happy with it.
>
> Reviewed-by: Sam James <sam@gentoo.org>
Thanks, I will install this shortly.
More information about the Libc-alpha
mailing list