Makefile: Add security compiling flags (RELRO) 40/301940/1
authorUnsung Lee <unsung.lee@samsung.com>
Fri, 24 Nov 2023 12:41:42 +0000 (21:41 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Tue, 28 Nov 2023 04:11:18 +0000 (13:11 +0900)
Add "-Wl,-z,relro" (Partial RELRO) in COMMON_FLAGS and LDFLAGS
to support RELRO (RELocation Read-Only).
It is used to defend against GOT-Overwrite attack by removeing write permission.

Change-Id: If15e159d5b2e5ad1a07e54098ac9051581881abe
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
Makefile

index cb22a93..6ce906c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -29,11 +29,13 @@ COMMON_FLAGS += -O2 -c \
        -fPIE \
        -Wformat -Wformat-security -Wno-format-nonliteral \
        -Wall -Wextra -Werror \
-       -Ikafel/include
+       -Ikafel/include \
+       -Wl,-z,relro
 
 CXXFLAGS += $(USER_DEFINES) $(COMMON_FLAGS) $(shell pkg-config --cflags protobuf) \
        -std=c++11 -fno-exceptions -Wno-unused -Wno-unused-parameter
-LDFLAGS += -pie -Wl,-z,noexecstack -lpthread $(shell pkg-config --libs protobuf)
+LDFLAGS += -pie -Wl,-z,noexecstack -lpthread $(shell pkg-config --libs protobuf) \
+          -Wl,-z,relro
 
 BIN = nsjail
 LIBS = kafel/libkafel.a