Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 |
| 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. |
| 10 | lcl_maybe_fortify = "${@base_conditional('DEBUG_BUILD','1','','-D_FORTIFY_SOURCE=2',d)}" |
| 11 | |
| 12 | SECURITY_CFLAGS ?= "-fstack-protector-all -pie -fpie ${lcl_maybe_fortify}" |
| 13 | SECURITY_NO_PIE_CFLAGS ?= "-fstack-protector-all ${lcl_maybe_fortify}" |
| 14 | |
| 15 | SECURITY_LDFLAGS ?= "-Wl,-z,relro,-z,now" |
| 16 | SECURITY_X_LDFLAGS ?= "-Wl,-z,relro" |
| 17 | |
| 18 | # powerpc does not get on with pie for reasons not looked into as yet |
| 19 | SECURITY_CFLAGS_powerpc = "-fstack-protector-all ${lcl_maybe_fortify}" |
| 20 | # Deal with ppc specific linker failures when using the cflags |
| 21 | SECURITY_CFLAGS_pn-dbus_powerpc = "" |
| 22 | SECURITY_CFLAGS_pn-dbus-ptest_powerpc = "" |
| 23 | SECURITY_CFLAGS_pn-libmatchbox_powerpc = "" |
| 24 | |
| 25 | # arm specific security flag issues |
| 26 | SECURITY_CFLAGS_pn-lttng-tools_arm = "${SECURITY_NO_PIE_CFLAGS}" |
| 27 | SECURITY_CFLAGS_pn-aspell = "${SECURITY_NO_PIE_CFLAGS}" |
| 28 | SECURITY_CFLAGS_pn-beecrypt = "${SECURITY_NO_PIE_CFLAGS}" |
| 29 | SECURITY_CFLAGS_pn-blktrace = "${SECURITY_NO_PIE_CFLAGS}" |
| 30 | SECURITY_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" |
| 34 | SECURITY_CFLAGS_pn-cups = "${SECURITY_NO_PIE_CFLAGS}" |
| 35 | SECURITY_CFLAGS_pn-curl = "-fstack-protector-all -pie -fpie" |
| 36 | SECURITY_CFLAGS_pn-db = "${SECURITY_NO_PIE_CFLAGS}" |
| 37 | SECURITY_CFLAGS_pn-directfb = "${SECURITY_NO_PIE_CFLAGS}" |
| 38 | SECURITY_CFLAGS_pn-glibc = "" |
| 39 | SECURITY_CFLAGS_pn-glibc-initial = "" |
| 40 | SECURITY_CFLAGS_pn-elfutils = "${SECURITY_NO_PIE_CFLAGS}" |
| 41 | SECURITY_CFLAGS_pn-enchant = "${SECURITY_NO_PIE_CFLAGS}" |
| 42 | SECURITY_CFLAGS_pn-expect = "${SECURITY_NO_PIE_CFLAGS}" |
| 43 | SECURITY_CFLAGS_pn-flac = "${SECURITY_NO_PIE_CFLAGS}" |
| 44 | SECURITY_CFLAGS_pn-flex = "${SECURITY_NO_PIE_CFLAGS}" |
| 45 | SECURITY_CFLAGS_pn-gcc = "${SECURITY_NO_PIE_CFLAGS}" |
| 46 | SECURITY_CFLAGS_pn-gcc-runtime = "${SECURITY_NO_PIE_CFLAGS}" |
| 47 | SECURITY_CFLAGS_pn-gcc-sanitizers = "${SECURITY_NO_PIE_CFLAGS}" |
| 48 | SECURITY_CFLAGS_pn-gdb = "${SECURITY_NO_PIE_CFLAGS}" |
| 49 | SECURITY_CFLAGS_pn-gmp = "${SECURITY_NO_PIE_CFLAGS}" |
| 50 | SECURITY_CFLAGS_pn-gnutls = "${SECURITY_NO_PIE_CFLAGS}" |
| 51 | SECURITY_CFLAGS_pn-grub = "" |
| 52 | SECURITY_CFLAGS_pn-grub-efi = "" |
| 53 | SECURITY_CFLAGS_pn-grub-efi-native = "" |
| 54 | SECURITY_CFLAGS_pn-grub-efi-x86-native = "" |
| 55 | SECURITY_CFLAGS_pn-grub-efi-i586-native = "" |
| 56 | SECURITY_CFLAGS_pn-grub-efi-x86-64-native = "" |
| 57 | SECURITY_CFLAGS_pn-gst-plugins-bad = "${SECURITY_NO_PIE_CFLAGS}" |
| 58 | SECURITY_CFLAGS_pn-gst-plugins-gl = "${SECURITY_NO_PIE_CFLAGS}" |
| 59 | SECURITY_CFLAGS_pn-gstreamer1.0-plugins-bad = "${SECURITY_NO_PIE_CFLAGS}" |
| 60 | SECURITY_CFLAGS_pn-gstreamer1.0-plugins-good = "${SECURITY_NO_PIE_CFLAGS}" |
| 61 | SECURITY_CFLAGS_pn-harfbuzz = "${SECURITY_NO_PIE_CFLAGS}" |
| 62 | SECURITY_CFLAGS_pn-kexec-tools = "${SECURITY_NO_PIE_CFLAGS}" |
| 63 | SECURITY_CFLAGS_pn-iptables = "${SECURITY_NO_PIE_CFLAGS}" |
| 64 | SECURITY_CFLAGS_pn-libaio = "${SECURITY_NO_PIE_CFLAGS}" |
| 65 | SECURITY_CFLAGS_pn-libcap = "${SECURITY_NO_PIE_CFLAGS}" |
| 66 | SECURITY_CFLAGS_pn-libgcc = "${SECURITY_NO_PIE_CFLAGS}" |
| 67 | SECURITY_CFLAGS_pn-libid3tag = "${SECURITY_NO_PIE_CFLAGS}" |
| 68 | SECURITY_CFLAGS_pn-libnewt = "${SECURITY_NO_PIE_CFLAGS}" |
| 69 | SECURITY_CFLAGS_pn-libglu = "${SECURITY_NO_PIE_CFLAGS}" |
| 70 | SECURITY_CFLAGS_pn-libpcap = "${SECURITY_NO_PIE_CFLAGS}" |
| 71 | SECURITY_CFLAGS_pn-libpcre = "${SECURITY_NO_PIE_CFLAGS}" |
| 72 | SECURITY_CFLAGS_pn-libproxy = "${SECURITY_NO_PIE_CFLAGS}" |
| 73 | SECURITY_CFLAGS_pn-lttng-ust = "${SECURITY_NO_PIE_CFLAGS}" |
| 74 | SECURITY_CFLAGS_pn-mesa = "${SECURITY_NO_PIE_CFLAGS}" |
| 75 | SECURITY_CFLAGS_pn-mesa-gl = "${SECURITY_NO_PIE_CFLAGS}" |
| 76 | SECURITY_CFLAGS_pn-openssl = "${SECURITY_NO_PIE_CFLAGS}" |
| 77 | SECURITY_CFLAGS_pn-opensp = "${SECURITY_NO_PIE_CFLAGS}" |
| 78 | SECURITY_CFLAGS_pn-ppp = "${SECURITY_NO_PIE_CFLAGS}" |
| 79 | SECURITY_CFLAGS_pn-python = "${SECURITY_NO_PIE_CFLAGS}" |
| 80 | SECURITY_CFLAGS_pn-python-imaging = "${SECURITY_NO_PIE_CFLAGS}" |
| 81 | SECURITY_CFLAGS_pn-python-pycurl = "${SECURITY_NO_PIE_CFLAGS}" |
| 82 | SECURITY_CFLAGS_pn-python-smartpm = "${SECURITY_NO_PIE_CFLAGS}" |
| 83 | SECURITY_CFLAGS_pn-python-numpy = "${SECURITY_NO_PIE_CFLAGS}" |
| 84 | SECURITY_CFLAGS_pn-python3 = "${SECURITY_NO_PIE_CFLAGS}" |
| 85 | SECURITY_CFLAGS_pn-tcl = "${SECURITY_NO_PIE_CFLAGS}" |
| 86 | SECURITY_CFLAGS_pn-tiff = "${SECURITY_NO_PIE_CFLAGS}" |
| 87 | SECURITY_CFLAGS_pn-valgrind = "${SECURITY_NO_PIE_CFLAGS}" |
| 88 | SECURITY_CFLAGS_pn-zlib = "${SECURITY_NO_PIE_CFLAGS}" |
| 89 | |
| 90 | # These 2 have text relco errors with the pie options enabled |
| 91 | SECURITY_CFLAGS_pn-ltp = "${SECURITY_NO_PIE_CFLAGS}" |
| 92 | SECURITY_CFLAGS_pn-pulseaudio = "${SECURITY_NO_PIE_CFLAGS}" |
| 93 | |
| 94 | TARGET_CFLAGS_append = " ${SECURITY_CFLAGS}" |
| 95 | TARGET_LDFLAGS_append = " ${SECURITY_LDFLAGS}" |
| 96 | |
| 97 | SECURITY_LDFLAGS_pn-xf86-video-fbdev = "${SECURITY_X_LDFLAGS}" |
| 98 | SECURITY_LDFLAGS_pn-xf86-video-intel = "${SECURITY_X_LDFLAGS}" |
| 99 | SECURITY_LDFLAGS_pn-xf86-video-omapfb = "${SECURITY_X_LDFLAGS}" |
| 100 | SECURITY_LDFLAGS_pn-xf86-video-omap = "${SECURITY_X_LDFLAGS}" |
| 101 | SECURITY_LDFLAGS_pn-xf86-video-vesa = "${SECURITY_X_LDFLAGS}" |
| 102 | SECURITY_LDFLAGS_pn-xf86-video-vmware = "${SECURITY_X_LDFLAGS}" |
| 103 | SECURITY_LDFLAGS_pn-xserver-xorg = "${SECURITY_X_LDFLAGS}" |