Skip to contentSkip to conversation

gcc: enable branch protection by standard

PATCH In review Ross Burton 3 participants 4 messages May 20, 2021 – May 21, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gcc: enable branch protection by standard

Pass --enable-standard-branch-protection. This is an aarch64-specific option (currently) which does nothing on other targets. On aarch64 this generates code uses BTI/PAC instructions to mitigate Return Orientated Programming attacks. This approach is backwards compatible and the code size/performance impact is typically negliable.

More details can be found at
https://events.static.linuxfound.org/sites/events/files/slides/slides_23.pdf

---
 meta/recipes-devtools/gcc/gcc-configure-common.inc | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-devtools/gcc/gcc-configure-common.inc +1 -0
index a64c4caf00..dc7f458b25 100644
@@ -40,6 +40,7 @@ EXTRA_OECONF = "\
     ${@get_gcc_mips_plt_setting(bb, d)} \
     ${@get_gcc_ppc_plt_settings(bb, d)} \
     ${@get_gcc_multiarch_setting(bb, d)} \
+	--enable-standard-branch-protection \
 "
 
 # glibc version is a minimum controlling whether features are enabled. 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 19 lines · Ross Burton

Pass --enable-standard-branch-protection. This is an aarch64-specific option (currently) which does nothing on other targets. On aarch64 this generates code uses BTI/PAC instructions to mitigate Return Orientated Programming attacks. This approach is backwards compatible and the code size/performance impact is typically negliable.

More details can be found at
https://events.static.linuxfound.org/sites/events/files/slides/slides_23.pdf

---
  meta/recipes-devtools/gcc/gcc-configure-common.inc | 1 +
  1 file changed, 1 insertion(+)
meta/recipes-devtools/gcc/gcc-configure-common.inc +0 -0
index a64c4caf00..dc7f458b25 100644

meta/recipes-devtools/gcc/gcc-configure-common.inc EXTRA_OECONF = "\ · line 45

Quoted 6 lines
meta/recipes-devtools/gcc/gcc-configure-common.inc +1 -0
@@ -40,6 +40,7 @@ EXTRA_OECONF = "\
      ${@get_gcc_mips_plt_setting(bb, d)} \
      ${@get_gcc_ppc_plt_settings(bb, d)} \
      ${@get_gcc_multiarch_setting(bb, d)} \
+	--enable-standard-branch-protection \
  "
 

lgtm

Quoted 6 lines
meta/recipes-devtools/gcc/gcc-configure-common.inc +0 -0
  # glibc version is a minimum controlling whether features are enabled.
#2 lore raw
In reply to Ross Burton

Hi,

Quoted 8 lines · Ross Burton

Pass --enable-standard-branch-protection. This is an aarch64-specific option (currently) which does nothing on other targets. On aarch64 this generates code uses BTI/PAC instructions to mitigate Return Orientated Programming attacks. This approach is backwards compatible and the code size/performance impact is typically negliable.

More details can be found at
https://events.static.linuxfound.org/sites/events/files/slides/slides_23.pdf

Do you recommend this for dunfell and other stable releases? Any requirements to gcc version? What about clang?

Cheers,

-Mikko

Quoted 24 lines
---
 meta/recipes-devtools/gcc/gcc-configure-common.inc | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-devtools/gcc/gcc-configure-common.inc +1 -0
index a64c4caf00..dc7f458b25 100644
@@ -40,6 +40,7 @@ EXTRA_OECONF = "\
     ${@get_gcc_mips_plt_setting(bb, d)} \
     ${@get_gcc_ppc_plt_settings(bb, d)} \
     ${@get_gcc_multiarch_setting(bb, d)} \
+	--enable-standard-branch-protection \
 "
 
 # glibc version is a minimum controlling whether features are enabled. 
Signature · 1 line
2.25.1
#3 lore raw
Quoted 9 lines · Mikko Rapeli

Hi,

Quoted 6 lines · Ross Burton

Pass --enable-standard-branch-protection. This is an aarch64-specific option (currently) which does nothing on other targets. On aarch64 this generates code uses BTI/PAC instructions to mitigate Return Orientated Programming attacks. This approach is backwards compatible and the code size/performance impact is typically negliable.

Quoted 5 lines
Quoted 2 lines

More details can be found at
https://events.static.linuxfound.org/sites/events/files/slides/slides_23.pdf

Do you recommend this for dunfell and other stable releases? Any requirements to gcc version? What about clang?

it can be backported to dunfell, but I would not recommend it unless we run whole set of testing.

clang does not have convenient configure switch like gcc, so you bring up a good point, if we added this via cmdline options instead via SECURITY_CFLAGS
then it will work homogeneously across clang and gcc, perhaps that might be a better approach as it will also extend to other prebuilt toolchains which may support this option but arent configured to default to them.

Ross, some thought might be needed.

Quoted 33 lines

Cheers,

-Mikko

Quoted 28 lines
---
  meta/recipes-devtools/gcc/gcc-configure-common.inc | 1 +
  1 file changed, 1 insertion(+)
meta/recipes-devtools/gcc/gcc-configure-common.inc +1 -0
index a64c4caf00..dc7f458b25 100644
@@ -40,6 +40,7 @@ EXTRA_OECONF = "\
      ${@get_gcc_mips_plt_setting(bb, d)} \
      ${@get_gcc_ppc_plt_settings(bb, d)} \
      ${@get_gcc_multiarch_setting(bb, d)} \
+	--enable-standard-branch-protection \
  "
 
  # glibc version is a minimum controlling whether features are enabled.
Signature · 1 line
2.25.1