Config.in: enable FORTIFY_SOURCE, PIC/PIE, RELRO, SSP by default
PATCH v3 1/1 Config.in: enable FORTIFY_SOURCE, PIC/PIE, RELRO, SSP by default
Enhance security by enabling FORTIFY_SOURCE, PIC/PIE, RELRO and SSP by default.
This could help making IoT more secure and fight against the assumption that buildroot does not support binary hardening (see
https://cyber-itl.org/2019/08/26/iot-data-writeup.html)
---
Changes v2 -> v3:
- Drop BR2_ENABLE_SSP comment from Config.in.legacy
- Drop condition on second RELRO default (after Yann E. Morin review)
- Set BR2_FORTIFY_SOURCE_1 by default (after Yann E. Morin and Matthew Weber review)
Changes v1 -> v2:
- Use RELRO_PARTIAL if toolchain does not support PIE
- Enable BR2_FORTIFY_SOURCE_2 by default
Config.in | 6 +++++- Config.in.legacy | 1 - 2 files changed, 5 insertions(+), 2 deletions(-)
Config.in +5 -1
@@ -715,6 +715,7 @@ comment "Security Hardening Options" config BR2_PIC_PIE bool "Build code with PIC/PIE" + default y depends on BR2_SHARED_LIBS depends on BR2_TOOLCHAIN_SUPPORTS_PIE help
@@ -727,7 +728,7 @@ comment "PIC/PIE needs a toolchain w/ PIE" choice bool "Stack Smashing Protection" - default BR2_SSP_ALL if BR2_ENABLE_SSP # legacy + default BR2_SSP_ALL depends on BR2_TOOLCHAIN_HAS_SSP help Enable stack smashing protection support using GCC's
@@ -789,6 +790,8 @@ comment "Stack Smashing Protection needs a toolchain w/ SSP" choice bool "RELRO Protection" + default BR2_RELRO_FULL if BR2_TOOLCHAIN_SUPPORTS_PIE + default BR2_RELRO_PARTIAL depends on BR2_SHARED_LIBS help Enable a link-time protection know as RELRO (RELocation Read
@@ -825,6 +828,7 @@ comment "RELocation Read Only (RELRO) needs shared libraries" choice bool "Buffer-overflow Detection (FORTIFY_SOURCE)" + default BR2_FORTIFY_SOURCE_1 depends on BR2_TOOLCHAIN_USES_GLIBC depends on !BR2_OPTIMIZE_0 help
Config.in.legacy +0 -1
@@ -3527,7 +3527,6 @@ config BR2_PACKAGE_PYTHON_PYXML PyXML is obsolete and its functionality is covered either via native Python XML support or python-lxml package. -# BR2_ENABLE_SSP is still referenced in Config.in (default in choice) config BR2_ENABLE_SSP bool "Stack Smashing protection now has different levels" help
Signature · 1 line
2.30.2
Yann E. MORIN
AppliedPATCH v3 1/1 Config.in: enable FORTIFY_SOURCE, PIC/PIE, RELRO, SSP by default
Fabrice, All,
On 2021-05-03 20:22 +0200, Fabrice Fontaine spake thusly:
Quoted 36 lines
Enhance security by enabling
FORTIFY_SOURCE, PIC/PIE, RELRO and SSP by default.This could help making IoT more secure and fight against the assumption that buildroot does not support binary hardening (see
https://cyber-itl.org/2019/08/26/iot-data-writeup.html)Signed-off-by Fabrice Fontaine <[email protected]>---
Changes v2 -> v3:
- DropBR2_ENABLE_SSPcomment from Config.in.legacy
- Drop condition on second RELRO default (after Yann E. Morin review)
- SetBR2_FORTIFY_SOURCE_1by default (after Yann E. Morin and Matthew Weber review)Changes v1 -> v2:
- UseRELRO_PARTIALif toolchain does not support PIE
- EnableBR2_FORTIFY_SOURCE_2by defaultConfig.in | 6 +++++- Config.in.legacy | 1 - 2 files changed, 5 insertions(+), 2 deletions(-)Config.in +1
-0@@ -715,6 +715,7 @@ comment "Security Hardening Options" config BR2_PIC_PIE bool "Build code with PIC/PIE" + default y depends on BR2_SHARED_LIBS depends on BR2_TOOLCHAIN_SUPPORTS_PIE help
Config.in comment "PIC/PIE needs a toolchain w/ PIE" · line 731
Quoted 5 lines
Config.in +1
-1@@ -727,7 +728,7 @@ comment "PIC/PIE needs a toolchain w/ PIE" choice bool "Stack Smashing Protection" - default BR2_SSP_ALL if BR2_ENABLE_SSP # legacy + default BR2_SSP_ALL
While discussing this with Matt on IRC, we noticed that SSP-all can have quite a significant impact on performance, and that SSP-strong (when available) would be a better default (resorting to SSP-regular otherwise).
Yes, this decreases the security level Buildroot wil use by default. But security is always to be balanced against performance, and this is always a tricky choice to make; I believe relaxing SSP was striking a good balance (especially since, today, most gcc versions should have SSP-strong available).
Applied to master, thank you!
Regards,
Yann E. MORIN.
Quoted 39 lines
Config.in +3
-0depends on BR2_TOOLCHAIN_HAS_SSP help Enable stack smashing protection support using GCC's@@ -789,6 +790,8 @@ comment "Stack Smashing Protection needs a toolchain w/ SSP" choice bool "RELRO Protection" + default BR2_RELRO_FULL if BR2_TOOLCHAIN_SUPPORTS_PIE + default BR2_RELRO_PARTIAL depends on BR2_SHARED_LIBS help Enable a link-time protection know as RELRO (RELocation Read@@ -825,6 +828,7 @@ comment "RELocation Read Only (RELRO) needs shared libraries" choice bool "Buffer-overflow Detection (FORTIFY_SOURCE)" + default BR2_FORTIFY_SOURCE_1 depends on BR2_TOOLCHAIN_USES_GLIBC depends on !BR2_OPTIMIZE_0 helpConfig.in.legacy +0
-1@@ -3527,7 +3527,6 @@ config BR2_PACKAGE_PYTHON_PYXML PyXML is obsolete and its functionality is covered either via native Python XML support or python-lxml package. -# BR2_ENABLE_SSP is still referenced in Config.in (default in choice) config BR2_ENABLE_SSP bool "Stack Smashing protection now has different levels" helpSignature · 6 lines
2.30.2 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH v3 1/1 Config.in: enable FORTIFY_SOURCE, PIC/PIE, RELRO, SSP by default
Le 03/05/2021 ? 22:41, Yann E. MORIN a ?crit?:
Quoted 12 lines
Fabrice, All,
On 2021-05-03 20:22 +0200, Fabrice Fontaine spake thusly:
Quoted 9 lines
Enhance security by enabling
FORTIFY_SOURCE, PIC/PIE, RELRO and SSP by default.This could help making IoT more secure and fight against the assumption that buildroot does not support binary hardening (see
https://cyber-itl.org/2019/08/26/iot-data-writeup.html)Signed-off-by Fabrice Fontaine <[email protected]>---
[...]
Quoted 24 lines
Quoted 13 lines
Config.in +1
-0@@ -715,6 +715,7 @@ comment "Security Hardening Options" config BR2_PIC_PIE bool "Build code with PIC/PIE" + default y depends on BR2_SHARED_LIBS depends on BR2_TOOLCHAIN_SUPPORTS_PIE helpConfig.in comment "PIC/PIE needs a toolchain w/ PIE" · line 731
Quoted 5 lines
Config.in +1
-1@@ -727,7 +728,7 @@ comment "PIC/PIE needs a toolchain w/ PIE" choice bool "Stack Smashing Protection" - default BR2_SSP_ALL if BR2_ENABLE_SSP # legacy + default BR2_SSP_ALLWhile discussing this with Matt on IRC, we noticed that SSP-all can have quite a significant impact on performance, and that SSP-strong (when available) would be a better default (resorting to SSP-regular otherwise).
Quoted 8 lines
Yes, this decreases the security level Buildroot wil use by default. But security is always to be balanced against performance, and this is always a tricky choice to make; I believe relaxing SSP was striking a good balance (especially since, today, most gcc versions should have SSP-strong available).
Applied to master, thank you!
It seems that some defconfigs are failing to build with this option by default:
https://gitlab.com/kubu93/buildroot/-/pipelines/299584088
At least:qemu_riscv32_virt_defconfig
https://gitlab.com/kubu93/buildroot/-/jobs/1247043359
qemu_s390x_defconfig
https://gitlab.com/kubu93/buildroot/-/jobs/1247043361
(I was testing the new qemu 6.0.0)
Best regards,
Romain
Quoted 3 lines
Regards,
Yann E. MORIN.
PATCH v3 1/1 Config.in: enable FORTIFY_SOURCE, PIC/PIE, RELRO, SSP by default
Hi Romain,
Thanks for warning me about these failures.
Le sam. 8 mai 2021 ? 17:37, Romain Naour <[email protected]> a ?crit :
Quoted 48 lines
Le 03/05/2021 ? 22:41, Yann E. MORIN a ?crit :
Quoted 12 lines
Fabrice, All,
On 2021-05-03 20:22 +0200, Fabrice Fontaine spake thusly:
Quoted 9 lines
Enhance security by enabling
FORTIFY_SOURCE, PIC/PIE, RELRO and SSP by default.This could help making IoT more secure and fight against the assumption that buildroot does not support binary hardening (see
https://cyber-itl.org/2019/08/26/iot-data-writeup.html)Signed-off-by Fabrice Fontaine <[email protected]>---
[...]
Quoted 24 lines
Quoted 13 lines
Config.in +1
-0@@ -715,6 +715,7 @@ comment "Security Hardening Options" config BR2_PIC_PIE bool "Build code with PIC/PIE" + default y depends on BR2_SHARED_LIBS depends on BR2_TOOLCHAIN_SUPPORTS_PIE helpConfig.in comment "PIC/PIE needs a toolchain w/ PIE" · line 731
Quoted 5 lines
Config.in +1
-1@@ -727,7 +728,7 @@ comment "PIC/PIE needs a toolchain w/ PIE" choice bool "Stack Smashing Protection" - default BR2_SSP_ALL if BR2_ENABLE_SSP # legacy + default BR2_SSP_ALLWhile discussing this with Matt on IRC, we noticed that SSP-all can have quite a significant impact on performance, and that SSP-strong (when available) would be a better default (resorting to SSP-regular otherwise).
Quoted 8 lines
Yes, this decreases the security level Buildroot wil use by default. But security is always to be balanced against performance, and this is always a tricky choice to make; I believe relaxing SSP was striking a good balance (especially since, today, most gcc versions should have SSP-strong available).
Applied to master, thank you!
Quoted 6 lines
It seems that some defconfigs are failing to build with this option by default:
https://gitlab.com/kubu93/buildroot/-/pipelines/299584088At least:
qemu_riscv32_virt_defconfig
https://gitlab.com/kubu93/buildroot/-/jobs/1247043359
This one should be fixed by
https://patchwork.ozlabs.org/project/buildroot/patch/20210508194155.3678473-2-fontaine.fabrice at gmail.com/
Quoted 3 lines
qemu_s390x_defconfig
https://gitlab.com/kubu93/buildroot/-/jobs/1247043361
This one should be fixed by
https://patchwork.ozlabs.org/project/buildroot/patch/20210509091800.708933-1-fontaine.fabrice at gmail.com/
Do you think there are other failures that are related to the activation of SSP?
Quoted 10 lines
(I was testing the new qemu 6.0.0)
Best regards,
RomainQuoted 3 lines
Regards,
Yann E. MORIN.
Best Regards,
Fabrice
PATCH v3 1/1 Config.in: enable FORTIFY_SOURCE, PIC/PIE, RELRO, SSP by default
Hi Fabrice,
Le 09/05/2021 ? 11:22, Fabrice Fontaine a ?crit?:
Quoted 3 lines
Hi Romain,
Thanks for warning me about these failures.
You're welcome.
Quoted 59 lines
Le sam. 8 mai 2021 ? 17:37, Romain Naour <[email protected]> a ?crit :
Quoted 48 lines
Le 03/05/2021 ? 22:41, Yann E. MORIN a ?crit :
Quoted 12 lines
Fabrice, All,
On 2021-05-03 20:22 +0200, Fabrice Fontaine spake thusly:
Quoted 9 lines
Enhance security by enabling
FORTIFY_SOURCE, PIC/PIE, RELRO and SSP by default.This could help making IoT more secure and fight against the assumption that buildroot does not support binary hardening (see
https://cyber-itl.org/2019/08/26/iot-data-writeup.html)Signed-off-by Fabrice Fontaine <[email protected]>---
[...]
Quoted 24 lines
Quoted 13 lines
Config.in +1
-0@@ -715,6 +715,7 @@ comment "Security Hardening Options" config BR2_PIC_PIE bool "Build code with PIC/PIE" + default y depends on BR2_SHARED_LIBS depends on BR2_TOOLCHAIN_SUPPORTS_PIE helpConfig.in comment "PIC/PIE needs a toolchain w/ PIE" · line 731
Quoted 5 lines
Config.in +1
-1@@ -727,7 +728,7 @@ comment "PIC/PIE needs a toolchain w/ PIE" choice bool "Stack Smashing Protection" - default BR2_SSP_ALL if BR2_ENABLE_SSP # legacy + default BR2_SSP_ALLWhile discussing this with Matt on IRC, we noticed that SSP-all can have quite a significant impact on performance, and that SSP-strong (when available) would be a better default (resorting to SSP-regular otherwise).
Quoted 8 lines
Yes, this decreases the security level Buildroot wil use by default. But security is always to be balanced against performance, and this is always a tricky choice to make; I believe relaxing SSP was striking a good balance (especially since, today, most gcc versions should have SSP-strong available).
Applied to master, thank you!
Quoted 6 lines
It seems that some defconfigs are failing to build with this option by default:
https://gitlab.com/kubu93/buildroot/-/pipelines/299584088At least:
qemu_riscv32_virt_defconfig
https://gitlab.com/kubu93/buildroot/-/jobs/1247043359This one should be fixed by
https://patchwork.ozlabs.org/project/buildroot/patch/20210508194155.3678473-2-fontaine.fabrice at gmail.com/Quoted 1 line
Quoted 6 lines
Quoted 2 lines
qemu_s390x_defconfig
https://gitlab.com/kubu93/buildroot/-/jobs/1247043361This one should be fixed by
https://patchwork.ozlabs.org/project/buildroot/patch/20210509091800.708933-1-fontaine.fabrice at gmail.com/Do you think there are other failures that are related to the activation of SSP?
I did another test with master branch and there are the same issues:
https://gitlab.com/kubu93/buildroot/-/pipelines/299615886
For nios2, the system doesn't boot as soon as BR2_PIC_PIE is set.
I started to look at ppc e500mc if the issue is also related to BR2_PIC_PIE option but I need time to investigate.
Best regards,
Romain
Quoted 14 lines
Quoted 10 lines
(I was testing the new qemu 6.0.0)
Best regards,
RomainQuoted 3 lines
Regards,
Yann E. MORIN.Best Regards,
Fabrice