From: Patrick Ohly <patrick.ohly@intel.com>
To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Cc: "openembedded-devel@lists.openembedded.org"
<openembedded-devel@lists.openembedded.org>
Subject: -pie in SECURITY_CFLAGS (was: Re: [meta-oe][PATCH 1/3] meson: update Meson devtool to 0.40.1)
Date: Fri, 09 Jun 2017 10:43:17 +0200 [thread overview]
Message-ID: <1496997797.30163.181.camel@intel.com> (raw)
In-Reply-To: <8806ffa9be8f4516b3f29cc1be0ceaf3@XBOX02.axis.com>
On Wed, 2017-06-07 at 21:44 +0000, Peter Kjellerstedt wrote:
> My guess is that the problem stems from the fact that security_flags.inc
> adds -pie (which is a linker flag) to SECURITY_CFLAGS rather than
> SECURITY_LDFLAGS...
I think I've seen that cause problems elsewhere when the CFLAGS came
after -shared, because then the compiler ended up trying to produce a
pie executable instead of a shared library.
Perhaps we should finally address that in security_flags.inc instead of
working around it?
Here's an untested patch which puts -pie where it belongs in the final
variables, without changing the pie/no pie API:
diff --git a/meta/conf/distro/include/security_flags.inc b/meta/conf/distro/include/security_flags.inc
index e162abeb3d9..b7b19355806 100644
--- a/meta/conf/distro/include/security_flags.inc
+++ b/meta/conf/distro/include/security_flags.inc
@@ -12,6 +12,9 @@ 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"
+# For history reasons and simplicity, -pie is listed here as part of CFLAGS.
+# In practice, it ends up getting used as part of LDFLAGS, as it should
+# be because it is a linker flag.
SECURITY_CFLAGS ?= "-fstack-protector-strong -pie -fpie ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
SECURITY_NO_PIE_CFLAGS ?= "-fstack-protector-strong ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
@@ -94,8 +97,8 @@ SECURITY_STRINGFORMAT_pn-busybox = ""
SECURITY_STRINGFORMAT_pn-gcc = ""
SECURITY_STRINGFORMAT_pn-oh-puzzles = ""
-TARGET_CFLAGS_append_class-target = " ${SECURITY_CFLAGS}"
-TARGET_LDFLAGS_append_class-target = " ${SECURITY_LDFLAGS}"
+TARGET_CFLAGS_append_class-target = " ${@ oe.utils.filter_out('-pie', '${SECURITY_CFLAGS}') }"
+TARGET_LDFLAGS_append_class-target = " ${@ oe.utils.filter('-pie', '${SECURITY_CFLAGS}') } ${SECURITY_LDFLAGS}"
SECURITY_LDFLAGS_remove_pn-gcc-runtime = "-fstack-protector-strong"
SECURITY_LDFLAGS_remove_pn-glibc = "-fstack-protector-strong"
--
Best Regards, Patrick Ohly
The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.
next prev parent reply other threads:[~2017-06-09 8:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-05 17:23 [meta-oe][PATCH 1/3] meson: update Meson devtool to 0.40.1 Adam C. Foltzer
2017-06-05 17:23 ` [meta-oe][PATCH 2/3] meson: fix build/host confusion for bbclass Adam C. Foltzer
2017-06-16 11:19 ` Linus Svensson
2017-06-26 13:07 ` Burton, Ross
2017-06-05 17:23 ` [meta-oe][PATCH 3/3] meson: add LDFLAGS to bbclass C/C++ link arguments Adam C. Foltzer
2017-06-07 21:48 ` Peter Kjellerstedt
2017-06-08 17:34 ` [meta-oe][PATCH v2] meson: add LDFLAGS to bbclass C/C++ link Adam C. Foltzer
2017-06-08 17:34 ` [meta-oe][PATCH v2] meson: add LDFLAGS to bbclass C/C++ link arguments Adam C. Foltzer
2017-06-08 17:44 ` Khem Raj
2017-06-08 17:50 ` Adam Foltzer
2017-06-26 12:58 ` Burton, Ross
2017-06-07 21:44 ` [meta-oe][PATCH 1/3] meson: update Meson devtool to 0.40.1 Peter Kjellerstedt
2017-06-09 8:43 ` Patrick Ohly [this message]
2017-06-09 13:24 ` -pie in SECURITY_CFLAGS (was: Re: [meta-oe][PATCH 1/3] meson: update Meson devtool to 0.40.1) Khem Raj
2017-06-09 14:34 ` Patrick Ohly
2017-06-09 17:32 ` Patrick Ohly
2017-06-12 7:04 ` Patrick Ohly
2017-06-12 14:47 ` Khem Raj
2017-06-12 18:23 ` Peter Kjellerstedt
2017-06-12 18:50 ` Khem Raj
2017-06-08 19:47 ` [meta-oe][PATCH 1/3] meson: update Meson devtool to 0.40.1 Martin Jansa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1496997797.30163.181.camel@intel.com \
--to=patrick.ohly@intel.com \
--cc=openembedded-devel@lists.openembedded.org \
--cc=peter.kjellerstedt@axis.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox