Skip to content

Commit 93f8662

Browse files
committed
build: Add _FORTIFY_SOURCE=3 support
Add support for _FORTIFY_SOURCE level 3. This is supported with glibc and with musl libc. Link: openwrt/openwrt#20313 Signed-off-by: Hauke Mehrtens <[email protected]>
1 parent 6268692 commit 93f8662

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

config/Config-build.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,11 @@ menu "Global build settings"
358358
config PKG_FORTIFY_SOURCE_NONE
359359
bool "None"
360360
config PKG_FORTIFY_SOURCE_1
361-
bool "Conservative"
361+
bool "Conservative Level 1"
362362
config PKG_FORTIFY_SOURCE_2
363-
bool "Aggressive"
363+
bool "Aggressive Level 2"
364+
config PKG_FORTIFY_SOURCE_3
365+
bool "Aggressive Level 3"
364366
endchoice
365367

366368
choice

include/hardening.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ ifdef CONFIG_PKG_FORTIFY_SOURCE_2
5151
TARGET_CFLAGS += -D_FORTIFY_SOURCE=2
5252
endif
5353
endif
54+
ifdef CONFIG_PKG_FORTIFY_SOURCE_3
55+
ifeq ($(strip $(PKG_FORTIFY_SOURCE)),1)
56+
TARGET_CFLAGS += -D_FORTIFY_SOURCE=3
57+
endif
58+
endif
5459
ifdef CONFIG_PKG_RELRO_PARTIAL
5560
ifeq ($(strip $(PKG_RELRO)),1)
5661
TARGET_CFLAGS += -Wl,-z,relro

toolchain/glibc/common.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ GLIBC_CONFIGURE:= \
6868
$(if $(CONFIG_PKG_RELRO_FULL),--enable-bind-now) \
6969
$(if $(CONFIG_PKG_FORTIFY_SOURCE_1),--enable-fortify-source=1) \
7070
$(if $(CONFIG_PKG_FORTIFY_SOURCE_2),--enable-fortify-source=2) \
71+
$(if $(CONFIG_PKG_FORTIFY_SOURCE_3),--enable-fortify-source=3) \
7172
--enable-kernel=6.6.0
7273

7374
export libc_cv_ssp=no

0 commit comments

Comments
 (0)