All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] security_flags.inc: use `?=' to set a default var-lcl_maybe_fortify
@ 2018-08-29  9:04 Hongxu Jia
  2018-08-29  9:04 ` [PATCH 2/2] security_flags.inc: add var-FSTACK_PROTECTOR to improve variable OVERRIDES Hongxu Jia
  0 siblings, 1 reply; 5+ messages in thread
From: Hongxu Jia @ 2018-08-29  9:04 UTC (permalink / raw)
  To: openembedded-core

- Since poky enable security flags+pie by default, tweak comments
to sync with it.
[poky commit]
491082c poky.conf: Enable security flags+pie by default
29d76b3 poky-lsb: Remove including security_flags.inc
[poky commit]

- Use `?=' to set a default lcl_maybe_fortify, it is helpful for
variable OVERRIDES.

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/conf/distro/include/security_flags.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/conf/distro/include/security_flags.inc b/meta/conf/distro/include/security_flags.inc
index 4e20a4d..e113f99 100644
--- a/meta/conf/distro/include/security_flags.inc
+++ b/meta/conf/distro/include/security_flags.inc
@@ -3,14 +3,14 @@
 # or both so a blacklist is maintained here. The idea would be over
 # time to reduce this list to nothing.
 # From a Yocto Project perspective, this file is included and tested
-# in the DISTRO="poky-lsb" configuration.
+# in the DISTRO="poky" configuration.
 
 GCCPIE ?= "--enable-default-pie"
 # If static PIE is known to work well, GLIBCPIE="--enable-static-pie" can be set
 
 # _FORTIFY_SOURCE requires -O1 or higher, so disable in debug builds as they use
 # -O0 which then results in a compiler warning.
-lcl_maybe_fortify = "${@oe.utils.conditional('DEBUG_BUILD','1','','-D_FORTIFY_SOURCE=2',d)}"
+lcl_maybe_fortify ?= "${@oe.utils.conditional('DEBUG_BUILD','1','','-D_FORTIFY_SOURCE=2',d)}"
 
 # Error on use of format strings that represent possible security problems
 SECURITY_STRINGFORMAT ?= "-Wformat -Wformat-security -Werror=format-security"
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] security_flags.inc: add var-FSTACK_PROTECTOR to improve variable OVERRIDES
  2018-08-29  9:04 [PATCH 1/2] security_flags.inc: use `?=' to set a default var-lcl_maybe_fortify Hongxu Jia
@ 2018-08-29  9:04 ` Hongxu Jia
  2018-08-29  9:18   ` Peter Kjellerstedt
  2018-08-29 14:01   ` [PATCH V2] security_flags.inc: add var-SECURITY_STACK_PROTECTOR " Hongxu Jia
  0 siblings, 2 replies; 5+ messages in thread
From: Hongxu Jia @ 2018-08-29  9:04 UTC (permalink / raw)
  To: openembedded-core

There are var-SECURITY_PIE_CFLAGS, var-lcl_maybe_fortify and
var-SECURITY_STRINGFORMAT which are helpful for OVERRIDES.

Also add var-FSTACK_PROTECTOR, and drop hardcoded `_remove'
overrides. Such as `4ca946c security_flags: use -fstack-protector-strong',
it s/-fstack-protector-all/-fstack-protector-strong/, only tweak
var-FSTACK_PROTECTOR is sufficient.

The fix does not have any side affect on SECURITY_CFLAGS of glibc/
glibc-initial/gcc-runtime, these three directly assigned with "".
...
SECURITY_CFLAGS_pn-glibc = ""
SECURITY_CFLAGS_pn-glibc-initial = ""
SECURITY_CFLAGS_pn-gcc-runtime = ""
...

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/conf/distro/include/security_flags.inc | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/meta/conf/distro/include/security_flags.inc b/meta/conf/distro/include/security_flags.inc
index e113f99..6602ec0 100644
--- a/meta/conf/distro/include/security_flags.inc
+++ b/meta/conf/distro/include/security_flags.inc
@@ -21,11 +21,13 @@ 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}"
+FSTACK_PROTECTOR ?= "-fstack-protector-strong"
 
-SECURITY_LDFLAGS ?= "-fstack-protector-strong -Wl,-z,relro,-z,now"
-SECURITY_X_LDFLAGS ?= "-fstack-protector-strong -Wl,-z,relro"
+SECURITY_CFLAGS ?= "${FSTACK_PROTECTOR} ${SECURITY_PIE_CFLAGS} ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
+SECURITY_NO_PIE_CFLAGS ?= "${FSTACK_PROTECTOR} ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
+
+SECURITY_LDFLAGS ?= "${FSTACK_PROTECTOR} -Wl,-z,relro,-z,now"
+SECURITY_X_LDFLAGS ?= "${FSTACK_PROTECTOR} -Wl,-z,relro"
 
 # powerpc does not get on with pie for reasons not looked into as yet
 GCCPIE_powerpc = ""
@@ -56,9 +58,9 @@ SECURITY_STRINGFORMAT_pn-gcc = ""
 TARGET_CC_ARCH_append_class-target = " ${SECURITY_CFLAGS}"
 TARGET_LDFLAGS_append_class-target = " ${SECURITY_LDFLAGS}"
 
-SECURITY_LDFLAGS_remove_pn-gcc-runtime = "-fstack-protector-strong"
-SECURITY_LDFLAGS_remove_pn-glibc = "-fstack-protector-strong"
-SECURITY_LDFLAGS_remove_pn-glibc-initial = "-fstack-protector-strong"
+FSTACK_PROTECTOR_pn-gcc-runtime = ""
+FSTACK_PROTECTOR_pn-glibc = ""
+FSTACK_PROTECTOR_pn-glibc-initial = ""
 # All xorg module drivers need to be linked this way as well and are
 # handled in recipes-graphics/xorg-driver/xorg-driver-common.inc
 SECURITY_LDFLAGS_pn-xserver-xorg = "${SECURITY_X_LDFLAGS}"
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] security_flags.inc: add var-FSTACK_PROTECTOR to improve variable OVERRIDES
  2018-08-29  9:04 ` [PATCH 2/2] security_flags.inc: add var-FSTACK_PROTECTOR to improve variable OVERRIDES Hongxu Jia
@ 2018-08-29  9:18   ` Peter Kjellerstedt
  2018-08-29  9:21     ` Hongxu Jia
  2018-08-29 14:01   ` [PATCH V2] security_flags.inc: add var-SECURITY_STACK_PROTECTOR " Hongxu Jia
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Kjellerstedt @ 2018-08-29  9:18 UTC (permalink / raw)
  To: Hongxu Jia, openembedded-core@lists.openembedded.org

> -----Original Message-----
> From: openembedded-core-bounces@lists.openembedded.org <openembedded-
> core-bounces@lists.openembedded.org> On Behalf Of Hongxu Jia
> Sent: den 29 augusti 2018 11:05
> To: openembedded-core@lists.openembedded.org
> Subject: [OE-core] [PATCH 2/2] security_flags.inc: add var-
> FSTACK_PROTECTOR to improve variable OVERRIDES
> 
> There are var-SECURITY_PIE_CFLAGS, var-lcl_maybe_fortify and
> var-SECURITY_STRINGFORMAT which are helpful for OVERRIDES.
> 
> Also add var-FSTACK_PROTECTOR, and drop hardcoded `_remove'
> overrides. Such as `4ca946c security_flags: use -fstack-protector-strong',
> it s/-fstack-protector-all/-fstack-protector-strong/, only tweak
> var-FSTACK_PROTECTOR is sufficient.
> 
> The fix does not have any side affect on SECURITY_CFLAGS of glibc/
> glibc-initial/gcc-runtime, these three directly assigned with "".
> ...
> SECURITY_CFLAGS_pn-glibc = ""
> SECURITY_CFLAGS_pn-glibc-initial = ""
> SECURITY_CFLAGS_pn-gcc-runtime = ""
> ...
> 
> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> ---
>  meta/conf/distro/include/security_flags.inc | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/meta/conf/distro/include/security_flags.inc
> b/meta/conf/distro/include/security_flags.inc
> index e113f99..6602ec0 100644
> --- a/meta/conf/distro/include/security_flags.inc
> +++ b/meta/conf/distro/include/security_flags.inc
> @@ -21,11 +21,13 @@ 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}"
> +FSTACK_PROTECTOR ?= "-fstack-protector-strong"

May I suggest to call it SECURITY_STACK_PROTECTOR instead? That aligns 
it better with the other variables.

> -SECURITY_LDFLAGS ?= "-fstack-protector-strong -Wl,-z,relro,-z,now"
> -SECURITY_X_LDFLAGS ?= "-fstack-protector-strong -Wl,-z,relro"
> +SECURITY_CFLAGS ?= "${FSTACK_PROTECTOR} ${SECURITY_PIE_CFLAGS} ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
> +SECURITY_NO_PIE_CFLAGS ?= "${FSTACK_PROTECTOR} ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
> +
> +SECURITY_LDFLAGS ?= "${FSTACK_PROTECTOR} -Wl,-z,relro,-z,now"
> +SECURITY_X_LDFLAGS ?= "${FSTACK_PROTECTOR} -Wl,-z,relro"
> 
>  # powerpc does not get on with pie for reasons not looked into as yet
>  GCCPIE_powerpc = ""
> @@ -56,9 +58,9 @@ SECURITY_STRINGFORMAT_pn-gcc = ""
>  TARGET_CC_ARCH_append_class-target = " ${SECURITY_CFLAGS}"
>  TARGET_LDFLAGS_append_class-target = " ${SECURITY_LDFLAGS}"
> 
> -SECURITY_LDFLAGS_remove_pn-gcc-runtime = "-fstack-protector-strong"
> -SECURITY_LDFLAGS_remove_pn-glibc = "-fstack-protector-strong"
> -SECURITY_LDFLAGS_remove_pn-glibc-initial = "-fstack-protector-strong"
> +FSTACK_PROTECTOR_pn-gcc-runtime = ""
> +FSTACK_PROTECTOR_pn-glibc = ""
> +FSTACK_PROTECTOR_pn-glibc-initial = ""
>  # All xorg module drivers need to be linked this way as well and are
>  # handled in recipes-graphics/xorg-driver/xorg-driver-common.inc
>  SECURITY_LDFLAGS_pn-xserver-xorg = "${SECURITY_X_LDFLAGS}"
> --
> 2.7.4

//Peter



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] security_flags.inc: add var-FSTACK_PROTECTOR to improve variable OVERRIDES
  2018-08-29  9:18   ` Peter Kjellerstedt
@ 2018-08-29  9:21     ` Hongxu Jia
  0 siblings, 0 replies; 5+ messages in thread
From: Hongxu Jia @ 2018-08-29  9:21 UTC (permalink / raw)
  To: Peter Kjellerstedt, openembedded-core@lists.openembedded.org

[-- Attachment #1: Type: text/plain, Size: 545 bytes --]

On 2018年08月29日 17:18, Peter Kjellerstedt wrote:
>> -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}"
>> +FSTACK_PROTECTOR ?= "-fstack-protector-strong"
> May I suggest to call it SECURITY_STACK_PROTECTOR instead? That aligns
> it better with the other variables.
>
I am no objection on it, after collection the reply, I

will send V2 to tweak it

//Hongxu


[-- Attachment #2: Type: text/html, Size: 1049 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V2] security_flags.inc: add var-SECURITY_STACK_PROTECTOR to improve variable OVERRIDES
  2018-08-29  9:04 ` [PATCH 2/2] security_flags.inc: add var-FSTACK_PROTECTOR to improve variable OVERRIDES Hongxu Jia
  2018-08-29  9:18   ` Peter Kjellerstedt
@ 2018-08-29 14:01   ` Hongxu Jia
  1 sibling, 0 replies; 5+ messages in thread
From: Hongxu Jia @ 2018-08-29 14:01 UTC (permalink / raw)
  To: openembedded-core

There are var-SECURITY_PIE_CFLAGS, var-lcl_maybe_fortify and
var-SECURITY_STRINGFORMAT which are helpful for OVERRIDES.

Also add var-SECURITY_STACK_PROTECTOR, and drop hardcoded `_remove'
overrides. Such as `4ca946c security_flags: use -fstack-protector-strong',
it s/-fstack-protector-all/-fstack-protector-strong/, only tweak
var-SECURITY_STACK_PROTECTOR is sufficient.

The fix does not have any side affect on SECURITY_CFLAGS of glibc/
glibc-initial/gcc-runtime, these three directly assigned with "".
...
SECURITY_CFLAGS_pn-glibc = ""
SECURITY_CFLAGS_pn-glibc-initial = ""
SECURITY_CFLAGS_pn-gcc-runtime = ""
...

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/conf/distro/include/security_flags.inc | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/meta/conf/distro/include/security_flags.inc b/meta/conf/distro/include/security_flags.inc
index e113f99..620978a 100644
--- a/meta/conf/distro/include/security_flags.inc
+++ b/meta/conf/distro/include/security_flags.inc
@@ -21,11 +21,13 @@ 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_STACK_PROTECTOR ?= "-fstack-protector-strong"
 
-SECURITY_LDFLAGS ?= "-fstack-protector-strong -Wl,-z,relro,-z,now"
-SECURITY_X_LDFLAGS ?= "-fstack-protector-strong -Wl,-z,relro"
+SECURITY_CFLAGS ?= "${SECURITY_STACK_PROTECTOR} ${SECURITY_PIE_CFLAGS} ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
+SECURITY_NO_PIE_CFLAGS ?= "${SECURITY_STACK_PROTECTOR} ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
+
+SECURITY_LDFLAGS ?= "${SECURITY_STACK_PROTECTOR} -Wl,-z,relro,-z,now"
+SECURITY_X_LDFLAGS ?= "${SECURITY_STACK_PROTECTOR} -Wl,-z,relro"
 
 # powerpc does not get on with pie for reasons not looked into as yet
 GCCPIE_powerpc = ""
@@ -56,9 +58,9 @@ SECURITY_STRINGFORMAT_pn-gcc = ""
 TARGET_CC_ARCH_append_class-target = " ${SECURITY_CFLAGS}"
 TARGET_LDFLAGS_append_class-target = " ${SECURITY_LDFLAGS}"
 
-SECURITY_LDFLAGS_remove_pn-gcc-runtime = "-fstack-protector-strong"
-SECURITY_LDFLAGS_remove_pn-glibc = "-fstack-protector-strong"
-SECURITY_LDFLAGS_remove_pn-glibc-initial = "-fstack-protector-strong"
+SECURITY_STACK_PROTECTOR_pn-gcc-runtime = ""
+SECURITY_STACK_PROTECTOR_pn-glibc = ""
+SECURITY_STACK_PROTECTOR_pn-glibc-initial = ""
 # All xorg module drivers need to be linked this way as well and are
 # handled in recipes-graphics/xorg-driver/xorg-driver-common.inc
 SECURITY_LDFLAGS_pn-xserver-xorg = "${SECURITY_X_LDFLAGS}"
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-08-29 14:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-29  9:04 [PATCH 1/2] security_flags.inc: use `?=' to set a default var-lcl_maybe_fortify Hongxu Jia
2018-08-29  9:04 ` [PATCH 2/2] security_flags.inc: add var-FSTACK_PROTECTOR to improve variable OVERRIDES Hongxu Jia
2018-08-29  9:18   ` Peter Kjellerstedt
2018-08-29  9:21     ` Hongxu Jia
2018-08-29 14:01   ` [PATCH V2] security_flags.inc: add var-SECURITY_STACK_PROTECTOR " Hongxu Jia

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.