summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/conf/distro/include/security_flags.inc83
1 files changed, 22 insertions, 61 deletions
diff --git a/meta/conf/distro/include/security_flags.inc b/meta/conf/distro/include/security_flags.inc
index f2eb224a77..dd713b9818 100644
--- a/meta/conf/distro/include/security_flags.inc
+++ b/meta/conf/distro/include/security_flags.inc
@@ -1,4 +1,4 @@
1# Setup extra CFLAGS and LDFLAGS which have 'security' benefits. These 1# Setup extra CFLAGS and LDFLAGS which have 'security' benefits. These
2# don't work universally, there are recipes which can't use one, the other 2# don't work universally, there are recipes which can't use one, the other
3# or both so a blacklist is maintained here. The idea would be over 3# or both so a blacklist is maintained here. The idea would be over
4# time to reduce this list to nothing. 4# time to reduce this list to nothing.
@@ -14,87 +14,45 @@ lcl_maybe_fortify = "${@base_conditional('DEBUG_BUILD','1','','-D_FORTIFY_SOURCE
14# Error on use of format strings that represent possible security problems 14# Error on use of format strings that represent possible security problems
15SECURITY_STRINGFORMAT ?= "-Wformat -Wformat-security -Werror=format-security" 15SECURITY_STRINGFORMAT ?= "-Wformat -Wformat-security -Werror=format-security"
16 16
17SECURITY_CFLAGS ?= "-fstack-protector-strong ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}" 17# Inject pie flags into compiler flags if not configured with gcc itself
18# especially useful with external toolchains
19SECURITY_PIE_CFLAGS ?= "${@'' if '${GCCPIE}' else '-pie -fPIE'}"
20
21SECURITY_NOPIE_CFLAGS ?= "-no-pie -fno-PIE"
22
23SECURITY_CFLAGS ?= "-fstack-protector-strong ${SECURITY_PIE_CFLAGS} ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
18SECURITY_NO_PIE_CFLAGS ?= "-fstack-protector-strong ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}" 24SECURITY_NO_PIE_CFLAGS ?= "-fstack-protector-strong ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
19 25
20SECURITY_LDFLAGS ?= "-fstack-protector-strong -Wl,-z,relro,-z,now" 26SECURITY_LDFLAGS ?= "-fstack-protector-strong -Wl,-z,relro,-z,now"
21SECURITY_X_LDFLAGS ?= "-fstack-protector-strong -Wl,-z,relro" 27SECURITY_X_LDFLAGS ?= "-fstack-protector-strong -Wl,-z,relro"
22 28
23# powerpc does not get on with pie for reasons not looked into as yet 29# powerpc does not get on with pie for reasons not looked into as yet
24SECURITY_CFLAGS_powerpc = "-fstack-protector-strong ${lcl_maybe_fortify}" 30SECURITY_CFLAGS_powerpc = "-fstack-protector-strong ${lcl_maybe_fortify} ${SECURITY_NOPIE_CFLAGS}"
25# Deal with ppc specific linker failures when using the cflags 31SECURITY_CFLAGS_pn-libgcc_powerpc = ""
26SECURITY_CFLAGS_pn-dbus_powerpc = ""
27SECURITY_CFLAGS_pn-dbus-ptest_powerpc = ""
28SECURITY_CFLAGS_pn-libmatchbox_powerpc = ""
29 32
30# arm specific security flag issues 33# arm specific security flag issues
31SECURITY_CFLAGS_pn-lttng-tools_arm = "${SECURITY_NO_PIE_CFLAGS}"
32SECURITY_CFLAGS_pn-aspell = "${SECURITY_NO_PIE_CFLAGS}"
33SECURITY_CFLAGS_pn-beecrypt = "${SECURITY_NO_PIE_CFLAGS}"
34SECURITY_CFLAGS_pn-coreutils = "${SECURITY_NO_PIE_CFLAGS}"
35SECURITY_CFLAGS_pn-cups = "${SECURITY_NO_PIE_CFLAGS}"
36SECURITY_CFLAGS_pn-db = "${SECURITY_NO_PIE_CFLAGS}"
37SECURITY_CFLAGS_pn-directfb = "${SECURITY_NO_PIE_CFLAGS}"
38SECURITY_CFLAGS_pn-glibc = "" 34SECURITY_CFLAGS_pn-glibc = ""
39SECURITY_CFLAGS_pn-glibc-initial = "" 35SECURITY_CFLAGS_pn-glibc-initial = ""
40SECURITY_CFLAGS_pn-elfutils = "${SECURITY_NO_PIE_CFLAGS}"
41SECURITY_CFLAGS_pn-enchant = "${SECURITY_NO_PIE_CFLAGS}"
42SECURITY_CFLAGS_pn-expect = "${SECURITY_NO_PIE_CFLAGS}"
43SECURITY_CFLAGS_pn-flac = "${SECURITY_NO_PIE_CFLAGS}"
44SECURITY_CFLAGS_pn-gcc = "${SECURITY_NO_PIE_CFLAGS}"
45SECURITY_CFLAGS_pn-gcc-runtime = "" 36SECURITY_CFLAGS_pn-gcc-runtime = ""
46SECURITY_CFLAGS_pn-gcc-sanitizers = "${SECURITY_NO_PIE_CFLAGS}"
47SECURITY_CFLAGS_pn-gdb = "${SECURITY_NO_PIE_CFLAGS}"
48SECURITY_CFLAGS_pn-gmp = "${SECURITY_NO_PIE_CFLAGS}"
49SECURITY_CFLAGS_pn-gnutls = "${SECURITY_NO_PIE_CFLAGS}"
50SECURITY_CFLAGS_pn-gpgme = "${SECURITY_NO_PIE_CFLAGS}"
51SECURITY_CFLAGS_pn-grub = "" 37SECURITY_CFLAGS_pn-grub = ""
52SECURITY_CFLAGS_pn-grub-efi = "" 38SECURITY_CFLAGS_pn-grub-efi = ""
53SECURITY_CFLAGS_pn-grub-efi-native = "" 39SECURITY_CFLAGS_pn-grub-efi-native = ""
54SECURITY_CFLAGS_pn-grub-efi-x86-native = "" 40SECURITY_CFLAGS_pn-grub-efi-x86-native = ""
55SECURITY_CFLAGS_pn-grub-efi-i586-native = "" 41SECURITY_CFLAGS_pn-grub-efi-i586-native = ""
56SECURITY_CFLAGS_pn-grub-efi-x86-64-native = "" 42SECURITY_CFLAGS_pn-grub-efi-x86-64-native = ""
57SECURITY_CFLAGS_pn-gstreamer1.0-plugins-bad = "${SECURITY_NO_PIE_CFLAGS}" 43
58SECURITY_CFLAGS_pn-gstreamer1.0-plugins-good = "${SECURITY_NO_PIE_CFLAGS}" 44SECURITY_CFLAGS_pn-mkelfimage_x86 = ""
59SECURITY_CFLAGS_pn-harfbuzz = "${SECURITY_NO_PIE_CFLAGS}" 45
60SECURITY_CFLAGS_pn-kexec-tools = "${SECURITY_NO_PIE_CFLAGS}" 46SECURITY_CFLAGS_pn-valgrind = "${SECURITY_NOPIE_CFLAGS}"
61SECURITY_CFLAGS_pn-iptables = "${SECURITY_NO_PIE_CFLAGS}" 47SECURITY_LDFLAGS_pn-valgrind = ""
62SECURITY_CFLAGS_pn-libaio = "${SECURITY_NO_PIE_CFLAGS}" 48SECURITY_CFLAGS_pn-sysklogd = "${SECURITY_NOPIE_CFLAGS}"
63SECURITY_CFLAGS_pn-libcap = "${SECURITY_NO_PIE_CFLAGS}" 49SECURITY_LDFLAGS_pn-sysklogd = ""
64SECURITY_CFLAGS_pn-libgcc = "${SECURITY_NO_PIE_CFLAGS}"
65SECURITY_CFLAGS_pn-libid3tag = "${SECURITY_NO_PIE_CFLAGS}"
66SECURITY_CFLAGS_pn-libnewt-python = "${SECURITY_NO_PIE_CFLAGS}"
67SECURITY_CFLAGS_pn-libglu = "${SECURITY_NO_PIE_CFLAGS}"
68SECURITY_CFLAGS_pn-libpcap = "${SECURITY_NO_PIE_CFLAGS}"
69SECURITY_CFLAGS_pn-libpcre = "${SECURITY_NO_PIE_CFLAGS}"
70SECURITY_CFLAGS_pn-libproxy = "${SECURITY_NO_PIE_CFLAGS}"
71SECURITY_CFLAGS_pn-mesa = "${SECURITY_NO_PIE_CFLAGS}"
72SECURITY_CFLAGS_pn-mesa-gl = "${SECURITY_NO_PIE_CFLAGS}"
73SECURITY_CFLAGS_pn-openssl = "${SECURITY_NO_PIE_CFLAGS}"
74SECURITY_CFLAGS_pn-opensp = "${SECURITY_NO_PIE_CFLAGS}"
75SECURITY_CFLAGS_pn-ppp = "${SECURITY_NO_PIE_CFLAGS}"
76SECURITY_CFLAGS_pn-python = "${SECURITY_NO_PIE_CFLAGS}"
77SECURITY_CFLAGS_pn-python-pycurl = "${SECURITY_NO_PIE_CFLAGS}"
78SECURITY_CFLAGS_pn-python-numpy = "${SECURITY_NO_PIE_CFLAGS}"
79SECURITY_CFLAGS_pn-python3-numpy = "${SECURITY_NO_PIE_CFLAGS}"
80SECURITY_CFLAGS_pn-python3-pycairo = "${SECURITY_NO_PIE_CFLAGS}"
81SECURITY_CFLAGS_pn-python3-pycurl = "${SECURITY_NO_PIE_CFLAGS}"
82SECURITY_CFLAGS_pn-python3-pygpgme = "${SECURITY_NO_PIE_CFLAGS}"
83SECURITY_CFLAGS_pn-python3 = "${SECURITY_NO_PIE_CFLAGS}"
84SECURITY_CFLAGS_pn-syslinux = "${SECURITY_NO_PIE_CFLAGS}"
85SECURITY_CFLAGS_pn-slang = "${SECURITY_NO_PIE_CFLAGS}"
86SECURITY_CFLAGS_pn-source-highlight = "${SECURITY_NO_PIE_CFLAGS}"
87SECURITY_CFLAGS_pn-tcl = "${SECURITY_NO_PIE_CFLAGS}"
88SECURITY_CFLAGS_pn-tiff = "${SECURITY_NO_PIE_CFLAGS}"
89SECURITY_CFLAGS_pn-valgrind = ""
90SECURITY_CFLAGS_pn-zlib = "${SECURITY_NO_PIE_CFLAGS}"
91 50
92# Recipes which fail to compile when elevating -Wformat-security to an error 51# Recipes which fail to compile when elevating -Wformat-security to an error
93SECURITY_STRINGFORMAT_pn-busybox = "" 52SECURITY_STRINGFORMAT_pn-busybox = ""
94SECURITY_STRINGFORMAT_pn-gcc = "" 53SECURITY_STRINGFORMAT_pn-gcc = ""
95SECURITY_STRINGFORMAT_pn-oh-puzzles = ""
96 54
97TARGET_CFLAGS_append_class-target = " ${SECURITY_CFLAGS}" 55TARGET_CC_ARCH_append_class-target = " ${SECURITY_CFLAGS}"
98TARGET_LDFLAGS_append_class-target = " ${SECURITY_LDFLAGS}" 56TARGET_LDFLAGS_append_class-target = " ${SECURITY_LDFLAGS}"
99 57
100SECURITY_LDFLAGS_remove_pn-gcc-runtime = "-fstack-protector-strong" 58SECURITY_LDFLAGS_remove_pn-gcc-runtime = "-fstack-protector-strong"
@@ -108,4 +66,7 @@ SECURITY_LDFLAGS_pn-xf86-video-vesa = "${SECURITY_X_LDFLAGS}"
108SECURITY_LDFLAGS_pn-xf86-video-vmware = "${SECURITY_X_LDFLAGS}" 66SECURITY_LDFLAGS_pn-xf86-video-vmware = "${SECURITY_X_LDFLAGS}"
109SECURITY_LDFLAGS_pn-xserver-xorg = "${SECURITY_X_LDFLAGS}" 67SECURITY_LDFLAGS_pn-xserver-xorg = "${SECURITY_X_LDFLAGS}"
110 68
111TARGET_CC_ARCH_append_pn-binutils = " ${SECURITY_CFLAGS} ${SELECTED_OPTIMIZATION}" 69TARGET_CC_ARCH_append_pn-binutils = " ${SELECTED_OPTIMIZATION}"
70TARGET_CC_ARCH_append_pn-gcc = " ${SELECTED_OPTIMIZATION}"
71TARGET_CC_ARCH_append_pn-gdb = " ${SELECTED_OPTIMIZATION}"
72TARGET_CC_ARCH_append_pn-perf = " ${SELECTED_OPTIMIZATION}"