kaniini / libucontext

ucontext implementation featuring glibc-compatible ABI
Other
106 stars 41 forks source link

Disable executable stack by adding note in assembly files #38

Closed Phoenix591 closed 2 years ago

Phoenix591 commented 2 years ago

I don't use libucontext much, but I finally got around to version 1.1, and since I finally turned on some extra QA output for Gentoo I got this warning.

* QA Notice: The following files contain writable and executable sections
 *  Files with such sections will not work properly (or at all!) on some
 *  architectures/operating systems.  A bug should be filed at
 *  https://bugs.gentoo.org/ to make sure the issue is fixed.
 *  For more information, see:
 *
 *    https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart
 *
 *  Please include the following list of files in your report:
 *  Note: Bugs should be filed for the respective maintainers
 *  of the package in question and not hardened@gentoo.org.
 * !WX --- --- usr/lib64/libucontext_posix.a:arch_x86_64_getcontext.S.o
 * !WX --- --- usr/lib64/libucontext_posix.a:arch_x86_64_setcontext.S.o
 * !WX --- --- usr/lib64/libucontext_posix.a:arch_x86_64_swapcontext.S.o
 * !WX --- --- usr/lib64/libucontext.a:arch_x86_64_getcontext.S.o
 * !WX --- --- usr/lib64/libucontext.a:arch_x86_64_setcontext.S.o
 * !WX --- --- usr/lib64/libucontext.a:arch_x86_64_swapcontext.S.o

I checked and saw that the assembly files indeed didn't have a note indicating if they needed an executable stack or not.

It seems this only happens when built under glibc.

If you would take a look, and do some more testing to ensure things don't break ( the basic make check passes still under musl, but the second test segfaults on glibc both with and without this change)

Gentoo bug filed by someone else.

kaniini commented 2 years ago

It would be less risky (of breakage) to just build with -Wa,--noexecstack in my opinion. I'll do that instead.

Can you get a backtrace of the glibc test failure?

kaniini commented 2 years ago

Done in https://gitea.treehouse.systems/ariadne/libucontext/commit/c50182d98c3191f9a2df7e16b3295b1865cda74e