Skip to contentSkip to conversation

eglibc: defaults to SSP

PATCH New Gustavo Zacarias 2 participants 6 messages Jul 27, 2013 – Aug 26, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eglibc: defaults to SSP

And it doesn't seem to do anything when disabling it.

---
 toolchain/toolchain-buildroot/Config.in.2 | 1 +
 1 file changed, 1 insertion(+)
toolchain/toolchain-buildroot/Config.in.2 +1 -0
index bf27e6b..f42d776 100644
@@ -19,6 +19,7 @@ comment "C++ support broken in uClibc with locale enabled with gcc 4.2"
 
 config BR2_TOOLCHAIN_BUILDROOT_USE_SSP
 	bool "Enable stack protection support"
+	depends on !BR2_TOOLCHAIN_BUILDROOT_EGLIBC
 	help
 	  Enable stack smashing protection support using GCCs
 	  -fstack-protector-all option.
Signature · 1 line
1.8.1.5
#1 lore raw

PATCH 1/1 eglibc: defaults to SSP

Dear Gustavo Zacarias,

Quoted 12 lines · Gustavo Zacarias

And it doesn't seem to do anything when disabling it.

---
 toolchain/toolchain-buildroot/Config.in.2 | 1 +
 1 file changed, 1 insertion(+)
toolchain/toolchain-buildroot/Config.in.2 +0 -0
index bf27e6b..f42d776 100644

toolchain/toolchain-buildroot/Config.in.2 comment "C++ support broken in uClibc with locale enabled with gcc 4.2" · line 25

Quoted 7 lines
toolchain/toolchain-buildroot/Config.in.2 +1 -0
@@ -19,6 +19,7 @@ comment "C++ support broken in uClibc with locale enabled with gcc 4.2"
 
 config BR2_TOOLCHAIN_BUILDROOT_USE_SSP
 	bool "Enable stack protection support"
+	depends on !BR2_TOOLCHAIN_BUILDROOT_EGLIBC
 	help
 	  Enable stack smashing protection support using GCCs
 	  -fstack-protector-all option.

I'm jumping on this as I was looking in a bit more details at the SSP support. It seems that GCC itself has a libssp library, and some external toolchains (such as the Linaro one) has a libssp.so that is apparently provided by GCC, while usually the SSP symbols (__stack_chk_fail and al.) are provided by the C library.

Currently BR2_TOOLCHAIN_BUILDROOT_USE_SSP is a toolchain option of the Buildroot internal backend. But what if I want to use SSP support with an external toolchain? You made this symbol depend
on !BR2_TOOLCHAIN_BUILDROOT_EGLIBC, but BR2_TOOLCHAIN_BUILDROOT_USE_SSP is also used to add the -fstack-protector-all to the CFLAGS when compiling all packages, which is also useful when eglibc is used, no?

Thanks for your insights,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#2 lore raw

PATCH 1/1 eglibc: defaults to SSP

Quoted 13 lines · Thomas Petazzoni

toolchain/toolchain-buildroot/Config.in.2 comment "C++ support broken in uClibc with locale enabled with gcc 4.2" · line 25

Quoted 6 lines

config BR2_TOOLCHAIN_BUILDROOT_USE_SSP

toolchain/toolchain-buildroot/Config.in.2 +1 -0
 	bool "Enable stack protection support"
+	depends on !BR2_TOOLCHAIN_BUILDROOT_EGLIBC
 	help
 	  Enable stack smashing protection support using GCCs
 	  -fstack-protector-all option.

I'm jumping on this as I was looking in a bit more details at the SSP support. It seems that GCC itself has a libssp library, and some external toolchains (such as the Linaro one) has a libssp.so that is apparently provided by GCC, while usually the SSP symbols (__stack_chk_fail and al.) are provided by the C library.

Quoted 8 lines

Currently BR2_TOOLCHAIN_BUILDROOT_USE_SSP is a toolchain option of the Buildroot internal backend. But what if I want to use SSP support with an external toolchain? You made this symbol depend
on !BR2_TOOLCHAIN_BUILDROOT_EGLIBC, but BR2_TOOLCHAIN_BUILDROOT_USE_SSP is also used to add the -fstack-protector-all to the CFLAGS when compiling all packages, which is also useful when eglibc is used, no?

Thanks for your insights,

Hi.
This patch was never applied since it's wrong (hence i ditched it from patchwork).
We need to build with -fstack-protector-all even for eglibc. Eglibc (at least the version we ship for internal toolchain) defaults to support/build stack protection support on so the option is valid. We don't have glibc support (yet - pending on your patches) but AFAIK for modern-ish versions of glibc that's also the case.
For external toolchains, well, there's varying support i take it depeding on toolchain component versions.
libssp wouldn't normally be necessary for modern toolchains except for MAYBE compatibility reasons which i don't think we should care about (old blobby apps linked against libssp) or if the toolchain has old components so libssp shouldn't necessarily be copied, at least not as a default.
Doing the nasty trick with sourcery 2013.05 ARM (qemu_arm_versatile) with BR2_TARGET_OPTIMIZATION="-fstack-protector-all" works fine for example without the need for tweaks.
Regards.

#3 lore raw

PATCH 1/1 eglibc: defaults to SSP

Dear Gustavo Zacarias,

Quoted 9 lines · Gustavo Zacarias

This patch was never applied since it's wrong (hence i ditched it from patchwork).
We need to build with -fstack-protector-all even for eglibc. Eglibc (at least the version we ship for internal toolchain) defaults to support/build stack protection support on so the option is valid. We don't have glibc support (yet - pending on your patches) but AFAIK for modern-ish versions of glibc that's also the case.
For external toolchains, well, there's varying support i take it depeding on toolchain component versions.

Quoted 8 lines

libssp wouldn't normally be necessary for modern toolchains except for MAYBE compatibility reasons which i don't think we should care about (old blobby apps linked against libssp) or if the toolchain has old components so libssp shouldn't necessarily be copied, at least not as a default.
Doing the nasty trick with sourcery 2013.05 ARM (qemu_arm_versatile) with BR2_TARGET_OPTIMIZATION="-fstack-protector-all" works fine for example without the need for tweaks.

Ok, so if we try to summarize this:

* The option to enable SSP should be in "Build options" and not in the "Toolchain" menu, because what it mainly does is adjust the CFLAGS/CXXFLAGS for all packages.

* In the case of the internal toolchain backend, it would make sure that the SSP support in the C library in enabled. I.e, nothing for eglibc/glibc, and enable SSP for uClibc.

* In the case of the external toolchain backend, we would need to have an option like "Toolchain supports SSP?" that the user must fill in. But this would mean the "Use SSP" option in "Build options" would have to depend on the "Toolchain supports SSP?" option.

Something like that?

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#4 lore raw

PATCH 1/1 eglibc: defaults to SSP

Quoted 10 lines · Thomas Petazzoni

Ok, so if we try to summarize this:

* The option to enable SSP should be in "Build options" and not in the "Toolchain" menu, because what it mainly does is adjust the CFLAGS/CXXFLAGS for all packages.

* In the case of the internal toolchain backend, it would make sure that the SSP support in the C library in enabled. I.e, nothing for eglibc/glibc, and enable SSP for uClibc.

Quoted 6 lines

* In the case of the external toolchain backend, we would need to have an option like "Toolchain supports SSP?" that the user must fill in. But this would mean the "Use SSP" option in "Build options" would have to depend on the "Toolchain supports SSP?" option.

Something like that?

Yes, i'd add for the last point "if custom external toolchain" because we can determine if the predefined toolchain has ssp when it's bumped/added with an internal knob.
It's possible libssp might need to be handled (copied) for some external toolchains depending on age too and how they were configured. Regards.

#5 lore raw

PATCH 1/1 eglibc: defaults to SSP

Dear Gustavo Zacarias,

Quoted 17 lines · Gustavo Zacarias
Quoted 15 lines · Thomas Petazzoni

Ok, so if we try to summarize this:

* The option to enable SSP should be in "Build options" and not in the "Toolchain" menu, because what it mainly does is adjust the CFLAGS/CXXFLAGS for all packages.

* In the case of the internal toolchain backend, it would make surey, that the SSP support in the C library in enabled. I.e, nothing for eglibc/glibc, and enable SSP for uClibc.

* In the case of the external toolchain backend, we would need to have an option like "Toolchain supports SSP?" that the user must fill in. But this would mean the "Use SSP" option in "Build options" would have to depend on the "Toolchain supports SSP?" option.

Quoted 5 lines
Quoted 1 line

Something like that?

Yes, i'd add for the last point "if custom external toolchain" because we can determine if the predefined toolchain has ssp when it's bumped/added with an internal knob.

Sure.

Quoted 2 lines

It's possible libssp might need to be handled (copied) for some external toolchains depending on age too and how they were configured.

Well, let's say we won't support this case for now :)

However, this brings me to the same question for mudflap support. Mudflap is on one side a compiler feature and library, but also a compiler flag that you must use to enable mudflap on a particular binary.

Should we have a "Enable mudflap usage" option in "Build options" that would build all binaries with -fmudflap, much like the "Enable SSP usage" would build all binaries with SSP usage?

To be honest, I am not sure it makes a lot of sense to build *all* binaries with mudflap enabled. I believe one would generally only build a selection of its own libraries/applications with mudflap, mudflap being an analysis tool rather than a "corrective" tool.

On the other hand, SSP is really a "corrective" feature in that it prevents some security holes from being exploited. For that reason, it makes sense to have a "Enable SSP usage" that passes -fstack-protector-all to all packages.

Does this makes sense, or should Mudflap support also have the possibility of being enabled for all packages?

Another question that comes to mind is that the "Enable SSP usage" option would be in "Build options", which sits *before* the "Toolchain" menu in menuconfig. However, the "Enable SSP usage" would only be visible if SSP is enabled at the toolchain level, so that might be confusing for the user. Thoughts?

Best regards,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com