blob: 14ac0bf32503ae6a604436bf71968a5cef2760f9 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# 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
3# or both so a blacklist is maintained here. The idea would be over
4# time to reduce this list to nothing.
5# From a Yocto Project perspective, this file is included and tested
6# in the DISTRO="poky-lsb" configuration.
7
8# _FORTIFY_SOURCE requires -O1 or higher, so disable in debug builds as they use
9# -O0 which then results in a compiler warning.
10lcl_maybe_fortify = "${@base_conditional('DEBUG_BUILD','1','','-D_FORTIFY_SOURCE=2',d)}"
11
12SECURITY_CFLAGS ?= "-fstack-protector-all -pie -fpie ${lcl_maybe_fortify}"
13SECURITY_NO_PIE_CFLAGS ?= "-fstack-protector-all ${lcl_maybe_fortify}"
14
15SECURITY_LDFLAGS ?= "-Wl,-z,relro,-z,now"
16SECURITY_X_LDFLAGS ?= "-Wl,-z,relro"
17
18# powerpc does not get on with pie for reasons not looked into as yet
19SECURITY_CFLAGS_powerpc = "-fstack-protector-all ${lcl_maybe_fortify}"
20# Deal with ppc specific linker failures when using the cflags
21SECURITY_CFLAGS_pn-dbus_powerpc = ""
22SECURITY_CFLAGS_pn-dbus-ptest_powerpc = ""
23SECURITY_CFLAGS_pn-libmatchbox_powerpc = ""
24
25# arm specific security flag issues
26SECURITY_CFLAGS_pn-lttng-tools_arm = "${SECURITY_NO_PIE_CFLAGS}"
27SECURITY_CFLAGS_pn-aspell = "${SECURITY_NO_PIE_CFLAGS}"
28SECURITY_CFLAGS_pn-beecrypt = "${SECURITY_NO_PIE_CFLAGS}"
29SECURITY_CFLAGS_pn-blktrace = "${SECURITY_NO_PIE_CFLAGS}"
30SECURITY_CFLAGS_pn-coreutils = "${SECURITY_NO_PIE_CFLAGS}"
31# Curl seems to check for FORTIFY_SOURCE in CFLAGS, but even assigned
32# to CPPFLAGS it gets picked into CFLAGS in bitbake.
33#TARGET_CPPFLAGS_pn-curl += "-D_FORTIFY_SOURCE=2"
34SECURITY_CFLAGS_pn-cups = "${SECURITY_NO_PIE_CFLAGS}"
35SECURITY_CFLAGS_pn-curl = "-fstack-protector-all -pie -fpie"
36SECURITY_CFLAGS_pn-db = "${SECURITY_NO_PIE_CFLAGS}"
37SECURITY_CFLAGS_pn-directfb = "${SECURITY_NO_PIE_CFLAGS}"
38SECURITY_CFLAGS_pn-glibc = ""
39SECURITY_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-flex = "${SECURITY_NO_PIE_CFLAGS}"
45SECURITY_CFLAGS_pn-gcc = "${SECURITY_NO_PIE_CFLAGS}"
46SECURITY_CFLAGS_pn-gcc-runtime = "${SECURITY_NO_PIE_CFLAGS}"
47SECURITY_CFLAGS_pn-gcc-sanitizers = "${SECURITY_NO_PIE_CFLAGS}"
48SECURITY_CFLAGS_pn-gdb = "${SECURITY_NO_PIE_CFLAGS}"
49SECURITY_CFLAGS_pn-gmp = "${SECURITY_NO_PIE_CFLAGS}"
50SECURITY_CFLAGS_pn-gnutls = "${SECURITY_NO_PIE_CFLAGS}"
51SECURITY_CFLAGS_pn-grub = ""
52SECURITY_CFLAGS_pn-grub-efi = ""
53SECURITY_CFLAGS_pn-grub-efi-native = ""
54SECURITY_CFLAGS_pn-grub-efi-x86-native = ""
55SECURITY_CFLAGS_pn-grub-efi-i586-native = ""
56SECURITY_CFLAGS_pn-grub-efi-x86-64-native = ""
57SECURITY_CFLAGS_pn-gst-plugins-bad = "${SECURITY_NO_PIE_CFLAGS}"
58SECURITY_CFLAGS_pn-gst-plugins-gl = "${SECURITY_NO_PIE_CFLAGS}"
59SECURITY_CFLAGS_pn-gstreamer1.0-plugins-bad = "${SECURITY_NO_PIE_CFLAGS}"
60SECURITY_CFLAGS_pn-gstreamer1.0-plugins-good = "${SECURITY_NO_PIE_CFLAGS}"
61SECURITY_CFLAGS_pn-harfbuzz = "${SECURITY_NO_PIE_CFLAGS}"
62SECURITY_CFLAGS_pn-kexec-tools = "${SECURITY_NO_PIE_CFLAGS}"
63SECURITY_CFLAGS_pn-iptables = "${SECURITY_NO_PIE_CFLAGS}"
64SECURITY_CFLAGS_pn-libaio = "${SECURITY_NO_PIE_CFLAGS}"
65SECURITY_CFLAGS_pn-libcap = "${SECURITY_NO_PIE_CFLAGS}"
66SECURITY_CFLAGS_pn-libgcc = "${SECURITY_NO_PIE_CFLAGS}"
67SECURITY_CFLAGS_pn-libid3tag = "${SECURITY_NO_PIE_CFLAGS}"
68SECURITY_CFLAGS_pn-libnewt = "${SECURITY_NO_PIE_CFLAGS}"
69SECURITY_CFLAGS_pn-libglu = "${SECURITY_NO_PIE_CFLAGS}"
70SECURITY_CFLAGS_pn-libpcap = "${SECURITY_NO_PIE_CFLAGS}"
71SECURITY_CFLAGS_pn-libpcre = "${SECURITY_NO_PIE_CFLAGS}"
72SECURITY_CFLAGS_pn-libproxy = "${SECURITY_NO_PIE_CFLAGS}"
73SECURITY_CFLAGS_pn-lttng-ust = "${SECURITY_NO_PIE_CFLAGS}"
74SECURITY_CFLAGS_pn-mesa = "${SECURITY_NO_PIE_CFLAGS}"
75SECURITY_CFLAGS_pn-mesa-gl = "${SECURITY_NO_PIE_CFLAGS}"
76SECURITY_CFLAGS_pn-openssl = "${SECURITY_NO_PIE_CFLAGS}"
77SECURITY_CFLAGS_pn-opensp = "${SECURITY_NO_PIE_CFLAGS}"
78SECURITY_CFLAGS_pn-ppp = "${SECURITY_NO_PIE_CFLAGS}"
79SECURITY_CFLAGS_pn-python = "${SECURITY_NO_PIE_CFLAGS}"
80SECURITY_CFLAGS_pn-python-imaging = "${SECURITY_NO_PIE_CFLAGS}"
81SECURITY_CFLAGS_pn-python-pycurl = "${SECURITY_NO_PIE_CFLAGS}"
82SECURITY_CFLAGS_pn-python-smartpm = "${SECURITY_NO_PIE_CFLAGS}"
83SECURITY_CFLAGS_pn-python-numpy = "${SECURITY_NO_PIE_CFLAGS}"
84SECURITY_CFLAGS_pn-python3 = "${SECURITY_NO_PIE_CFLAGS}"
85SECURITY_CFLAGS_pn-tcl = "${SECURITY_NO_PIE_CFLAGS}"
86SECURITY_CFLAGS_pn-tiff = "${SECURITY_NO_PIE_CFLAGS}"
87SECURITY_CFLAGS_pn-valgrind = "${SECURITY_NO_PIE_CFLAGS}"
88SECURITY_CFLAGS_pn-zlib = "${SECURITY_NO_PIE_CFLAGS}"
89
90# These 2 have text relco errors with the pie options enabled
91SECURITY_CFLAGS_pn-ltp = "${SECURITY_NO_PIE_CFLAGS}"
92SECURITY_CFLAGS_pn-pulseaudio = "${SECURITY_NO_PIE_CFLAGS}"
93
94TARGET_CFLAGS_append = " ${SECURITY_CFLAGS}"
95TARGET_LDFLAGS_append = " ${SECURITY_LDFLAGS}"
96
97SECURITY_LDFLAGS_pn-xf86-video-fbdev = "${SECURITY_X_LDFLAGS}"
98SECURITY_LDFLAGS_pn-xf86-video-intel = "${SECURITY_X_LDFLAGS}"
99SECURITY_LDFLAGS_pn-xf86-video-omapfb = "${SECURITY_X_LDFLAGS}"
100SECURITY_LDFLAGS_pn-xf86-video-omap = "${SECURITY_X_LDFLAGS}"
101SECURITY_LDFLAGS_pn-xf86-video-vesa = "${SECURITY_X_LDFLAGS}"
102SECURITY_LDFLAGS_pn-xf86-video-vmware = "${SECURITY_X_LDFLAGS}"
103SECURITY_LDFLAGS_pn-xserver-xorg = "${SECURITY_X_LDFLAGS}"