From patchwork Sat Jul 1 14:23:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khem Raj X-Patchwork-Id: 106817 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3562100qge; Sat, 1 Jul 2017 07:25:08 -0700 (PDT) X-Received: by 10.98.211.140 with SMTP id z12mr973310pfk.231.1498919108586; Sat, 01 Jul 2017 07:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498919108; cv=none; d=google.com; s=arc-20160816; b=fiDJkugZhk9WR0kl+MtLJOoolNlUarxZzFCDaiQokSqsck/AJik7X4Lbf1aw332W5F lY+OMD7C2C09/nmw2IqFWDoW2sceXcQDvNBZKPDIDi+8DPUgAzE+BAL2uDJ8yaz69mkV ld5OEScjSXOPChRKeqFRZEEO7yJkENm51m1kMZNG8QJNXrSFsYX5o6Ee5MswfWDAyCtM a49dTBhEMXvvikIWe1cPNgs08ugSFq0zwdWZg7f3AgEfv59wVj6I+g1EJA4Szj166QGb LZ5uTGvb3HmzAht9yYyAf+itk83OA849z8qndW0/lSL9FvqRKf8glxIIPRnPf0zqzJxy CqDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=JWeDwaWtj06/i3dg9SaFbWqY8aS+gMX5HOx7f4Yuy3k=; b=C4FB+VZpsc4YV7DIqkT1RhCPxeK/MEYLUGZ4tG5LVbedfVpU2VfcHzYEpi26aAbAn9 sBzhDngRewn1e3u6F2ohHZ4NoalBLiI8vuJfnGpW645y6ghtykLYWzH9mmvOgFoP8U/i eRFPkmJCPgv2GFIrvNh3j5K9pOq8Hth9hAjI3gkakCAN7g35F3G5XsQiwkfIt8JOIeLp pRTWYY/MXO0I0JvJXHvzHHpqYm83+7zhEkjoRDA1y9+n9XqBcQ4iGIzYIJYkm3g0TLmv 46rYym9bhvaX88ow/wWIS56QO80Mz6hRRzS3t3sW76qWFo68aUG4daUcqisFWglo9adH /TCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.b=SMz7/xgi; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from mail.openembedded.org (mail.openembedded.org. [140.211.169.62]) by mx.google.com with ESMTP id b8si8850554plk.87.2017.07.01.07.25.08; Sat, 01 Jul 2017 07:25:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) client-ip=140.211.169.62; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.b=SMz7/xgi; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from review.yoctoproject.org (localhost [127.0.0.1]) by mail.openembedded.org (Postfix) with ESMTP id 8AEB8782B5; Sat, 1 Jul 2017 14:24:49 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by mail.openembedded.org (Postfix) with ESMTP id 40E2978293 for ; Sat, 1 Jul 2017 14:23:44 +0000 (UTC) Received: by mail-pf0-f196.google.com with SMTP id z6so20458357pfk.3 for ; Sat, 01 Jul 2017 07:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UXgmUCBofunwR9lkagtgjwRHTyzR0jHdxWZ35GeKM5Y=; b=SMz7/xgi38Rco1BQTqXG7xdHbr4ZjENvCvlewlm4gPZ1HnShxhM1Y9whITYo0hJXlt 2WP1qJVckemaindE9ykfZ0dLhjz9ZldlyYvsb0zxhAeP5R6LJxXTmkQLzaeK9JLfOsMe 3wAoW0fPCVlXEP3L4vSCgYv7+tVdDf9bmc6a8WlwhW0Ix3JXZM0sNDDJ5dCjG2VEXnVK plWfkVz0A7r8lkjZTqcBy/zp2/uCPipgh/qBDgKmk/UIwbuX+aaDprOoqQT1i/idu52W mfM449zrKD+yYcy4NA/eH5GMHltiYj7XOLs+hrdtYFdwiwVhf2YRKL/XAOZmDYwLtzFx AUbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UXgmUCBofunwR9lkagtgjwRHTyzR0jHdxWZ35GeKM5Y=; b=Ruz3tts/9o18F2l650PzGrCHbokeoQtEfXt9pBGvxLJ+N49HTiclZ2XMgJ5DwfzRp5 i9GuJTU7/0gnXAmKoIShteixOlXqHIUms87+P4ad5Qv40Yqrs7ugoMjrJqXGvOr3TJFQ uRx/SbFeN9I+IpKSDDe3zdxle/1PNnxCsGkOBSFQ291pbo0+KHgKGZRJhKTE9rDKfjJ4 erL5+P0hdfU1k3bfUl2kYCIXRvIMm6KuMFqogVqvIfYB8VwaOr4OpcRTcO9xmsSJ8r+s hNonSF/qtZO/7Y2eA26HvhcsearpaSVnPhthiyq/sxQW1p0zywhz/Kpo5iBOoBtS8NNi eFGw== X-Gm-Message-State: AIVw110YRuQeQZolkj6x4sZeCGuMJ33w71g36ZSX6ct/PXlEldVRwmru IoGYjGwvf41DzPh/ X-Received: by 10.84.241.67 with SMTP id u3mr969602plm.30.1498919026051; Sat, 01 Jul 2017 07:23:46 -0700 (PDT) Received: from localhost.localdomain ([2601:646:8882:b8c::3df3]) by smtp.gmail.com with ESMTPSA id 17sm25026909pfn.84.2017.07.01.07.23.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Jul 2017 07:23:45 -0700 (PDT) From: Khem Raj To: openembedded-core@lists.openembedded.org Date: Sat, 1 Jul 2017 07:23:08 -0700 Message-Id: X-Mailer: git-send-email 2.13.2 In-Reply-To: References: Subject: [OE-core] [PATCH 05/19] security_flags.inc: Delete pinnings for SECURITY_NO_PIE_CFLAGS X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: openembedded-core-bounces@lists.openembedded.org Errors-To: openembedded-core-bounces@lists.openembedded.org GCC is configured correctly to pass PIE cflags/ldflags Signed-off-by: Khem Raj --- meta/conf/distro/include/security_flags.inc | 83 ++++++++--------------------- 1 file changed, 22 insertions(+), 61 deletions(-) -- 2.13.2 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core 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 @@ -# Setup extra CFLAGS and LDFLAGS which have 'security' benefits. These +# Setup extra CFLAGS and LDFLAGS which have 'security' benefits. These # don't work universally, there are recipes which can't use one, the other # or both so a blacklist is maintained here. The idea would be over # time to reduce this list to nothing. @@ -14,87 +14,45 @@ lcl_maybe_fortify = "${@base_conditional('DEBUG_BUILD','1','','-D_FORTIFY_SOURCE # Error on use of format strings that represent possible security problems SECURITY_STRINGFORMAT ?= "-Wformat -Wformat-security -Werror=format-security" -SECURITY_CFLAGS ?= "-fstack-protector-strong ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}" +# Inject pie flags into compiler flags if not configured with gcc itself +# especially useful with external toolchains +SECURITY_PIE_CFLAGS ?= "${@'' if '${GCCPIE}' else '-pie -fPIE'}" + +SECURITY_NOPIE_CFLAGS ?= "-no-pie -fno-PIE" + +SECURITY_CFLAGS ?= "-fstack-protector-strong ${SECURITY_PIE_CFLAGS} ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}" SECURITY_NO_PIE_CFLAGS ?= "-fstack-protector-strong ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}" SECURITY_LDFLAGS ?= "-fstack-protector-strong -Wl,-z,relro,-z,now" SECURITY_X_LDFLAGS ?= "-fstack-protector-strong -Wl,-z,relro" # powerpc does not get on with pie for reasons not looked into as yet -SECURITY_CFLAGS_powerpc = "-fstack-protector-strong ${lcl_maybe_fortify}" -# Deal with ppc specific linker failures when using the cflags -SECURITY_CFLAGS_pn-dbus_powerpc = "" -SECURITY_CFLAGS_pn-dbus-ptest_powerpc = "" -SECURITY_CFLAGS_pn-libmatchbox_powerpc = "" +SECURITY_CFLAGS_powerpc = "-fstack-protector-strong ${lcl_maybe_fortify} ${SECURITY_NOPIE_CFLAGS}" +SECURITY_CFLAGS_pn-libgcc_powerpc = "" # arm specific security flag issues -SECURITY_CFLAGS_pn-lttng-tools_arm = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-aspell = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-beecrypt = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-coreutils = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-cups = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-db = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-directfb = "${SECURITY_NO_PIE_CFLAGS}" SECURITY_CFLAGS_pn-glibc = "" SECURITY_CFLAGS_pn-glibc-initial = "" -SECURITY_CFLAGS_pn-elfutils = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-enchant = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-expect = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-flac = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-gcc = "${SECURITY_NO_PIE_CFLAGS}" SECURITY_CFLAGS_pn-gcc-runtime = "" -SECURITY_CFLAGS_pn-gcc-sanitizers = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-gdb = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-gmp = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-gnutls = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-gpgme = "${SECURITY_NO_PIE_CFLAGS}" SECURITY_CFLAGS_pn-grub = "" SECURITY_CFLAGS_pn-grub-efi = "" SECURITY_CFLAGS_pn-grub-efi-native = "" SECURITY_CFLAGS_pn-grub-efi-x86-native = "" SECURITY_CFLAGS_pn-grub-efi-i586-native = "" SECURITY_CFLAGS_pn-grub-efi-x86-64-native = "" -SECURITY_CFLAGS_pn-gstreamer1.0-plugins-bad = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-gstreamer1.0-plugins-good = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-harfbuzz = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-kexec-tools = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-iptables = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-libaio = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-libcap = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-libgcc = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-libid3tag = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-libnewt-python = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-libglu = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-libpcap = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-libpcre = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-libproxy = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-mesa = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-mesa-gl = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-openssl = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-opensp = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-ppp = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-python = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-python-pycurl = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-python-numpy = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-python3-numpy = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-python3-pycairo = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-python3-pycurl = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-python3-pygpgme = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-python3 = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-syslinux = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-slang = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-source-highlight = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-tcl = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-tiff = "${SECURITY_NO_PIE_CFLAGS}" -SECURITY_CFLAGS_pn-valgrind = "" -SECURITY_CFLAGS_pn-zlib = "${SECURITY_NO_PIE_CFLAGS}" + +SECURITY_CFLAGS_pn-mkelfimage_x86 = "" + +SECURITY_CFLAGS_pn-valgrind = "${SECURITY_NOPIE_CFLAGS}" +SECURITY_LDFLAGS_pn-valgrind = "" +SECURITY_CFLAGS_pn-sysklogd = "${SECURITY_NOPIE_CFLAGS}" +SECURITY_LDFLAGS_pn-sysklogd = "" # Recipes which fail to compile when elevating -Wformat-security to an error SECURITY_STRINGFORMAT_pn-busybox = "" SECURITY_STRINGFORMAT_pn-gcc = "" -SECURITY_STRINGFORMAT_pn-oh-puzzles = "" -TARGET_CFLAGS_append_class-target = " ${SECURITY_CFLAGS}" +TARGET_CC_ARCH_append_class-target = " ${SECURITY_CFLAGS}" TARGET_LDFLAGS_append_class-target = " ${SECURITY_LDFLAGS}" SECURITY_LDFLAGS_remove_pn-gcc-runtime = "-fstack-protector-strong" @@ -108,4 +66,7 @@ SECURITY_LDFLAGS_pn-xf86-video-vesa = "${SECURITY_X_LDFLAGS}" SECURITY_LDFLAGS_pn-xf86-video-vmware = "${SECURITY_X_LDFLAGS}" SECURITY_LDFLAGS_pn-xserver-xorg = "${SECURITY_X_LDFLAGS}" -TARGET_CC_ARCH_append_pn-binutils = " ${SECURITY_CFLAGS} ${SELECTED_OPTIMIZATION}" +TARGET_CC_ARCH_append_pn-binutils = " ${SELECTED_OPTIMIZATION}" +TARGET_CC_ARCH_append_pn-gcc = " ${SELECTED_OPTIMIZATION}" +TARGET_CC_ARCH_append_pn-gdb = " ${SELECTED_OPTIMIZATION}" +TARGET_CC_ARCH_append_pn-perf = " ${SELECTED_OPTIMIZATION}"