diff options
author | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-01-01 15:27:42 -0800 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-02 11:34:55 +0100 |
commit | 06da50afc71a5ab2bc63de54c66930a2dbe379cd (patch) | |
tree | 96c1abbc6216aa31479075261b9a9ba4366aa351 /Userland/DynamicLoader/CMakeLists.txt | |
parent | bf3772362a79984fa9226a12a147fb5a94a4e648 (diff) | |
download | serenity-06da50afc71a5ab2bc63de54c66930a2dbe379cd.zip |
Build + LibC: Enable -fstack-protector-strong in user space
Modify the user mode runtime to insert stack canaries to find stack corruptions.
The `-fstack-protector-strong` variant was chosen because it catches more
issues than vanilla `-fstack-protector`, but doesn't have substantial
performance impact like `-fstack-protector-all`.
Details:
-fstack-protector enables stack protection for vulnerable functions that contain:
* A character array larger than 8 bytes.
* An 8-bit integer array larger than 8 bytes.
* A call to alloca() with either a variable size or a constant size bigger than 8 bytes.
-fstack-protector-strong enables stack protection for vulnerable functions that contain:
* An array of any size and type.
* A call to alloca().
* A local variable that has its address taken.
Example of it catching corrupting in the `stack-smash` test:
```
courage ~ $ ./user/Tests/LibC/stack-smash
[+] Starting the stack smash ...
Error: Stack protector failure, stack smashing detected!
Shell: Job 1 (/usr/Tests/LibC/stack-smash) Aborted
```
Diffstat (limited to 'Userland/DynamicLoader/CMakeLists.txt')
-rw-r--r-- | Userland/DynamicLoader/CMakeLists.txt | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/DynamicLoader/CMakeLists.txt b/Userland/DynamicLoader/CMakeLists.txt index 7c763f0557..f870efe9ca 100644 --- a/Userland/DynamicLoader/CMakeLists.txt +++ b/Userland/DynamicLoader/CMakeLists.txt @@ -18,6 +18,9 @@ set(SOURCES ${LOADER_SOURCES} ${AK_SOURCES} ${ELF_SOURCES} ${LIBC_SOURCES1} ${LI set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -nostdlib -pie -fpic -DNO_TLS") +set_source_files_properties (../../Libraries/LibC/ssp.cpp PROPERTIES COMPILE_FLAGS + "-fno-stack-protector") + add_executable(Loader.so ${SOURCES}) target_link_options(Loader.so PRIVATE LINKER:--no-dynamic-linker) install(TARGETS Loader.so RUNTIME DESTINATION usr/lib/) |