From 79328b2aba6192caf28f560881e56ff23fcb7294 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Sat, 2 Jan 2021 03:02:42 -0800 Subject: [PATCH] Kernel: Enable -fstack-protector-strong (again) Insert stack canaries to find stack corruptions in the kernel. It looks like this was enabled in the past (842716a) but appears to have been lost during the CMake conversion. The `-fstack-protector-strong` variant was chosen because it catches more issues than `-fstack-protector`, but doesn't have substantial performance impact like `-fstack-protector-all`. --- Kernel/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index c19ac9a4cb..451060bf2b 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -267,6 +267,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -DKERNEL") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pie -fPIE -fno-rtti -ffreestanding -fbuiltin") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-80387 -mno-mmx -mno-sse -mno-sse2") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-asynchronous-unwind-tables") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib -nostdinc -nostdinc++") add_link_options(LINKER:-T ${CMAKE_CURRENT_BINARY_DIR}/linker.ld -nostdlib)