-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Enable stack smash protections by default #13175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
+1 for maybe enabling ssp by default, but please let's not introduce polemic variables like I suggest adding a per-CPU feature for ssp and enabling the module through that, or maybe let's just add
That's not minimal. |
I just wanted to make sure people setting this variable are aware of the consequences. I don't have any strong opinion on the name of the environment variable, what would you prefer instead?
What's the advantage of doing it this way? Are there any CPUs for which it shouldn't be enabled?
To avoid vaguely defined terms such as "minimal" and to be more exact: It's |
those that don't support it: |
Do you have further information on why these architectures do not support SSP? Do they use an old GCC version which does not have Is it possible to implement a backlisting approach with |
According to Murdock it seems to be ATmega, MSP430 and pic32. |
cbf3c2f
to
4f8f280
Compare
Renamed the environment variable to |
Please get rid of the variable. The way in RIOT to select use of something (including ssp) is by using a module. If something is only available on some architectures / toolchains, we use a feature in addition to the module. If something should be default, it goes into |
So concretely:
But we will need more code size / bss / runtime cost evaluations before making this default. |
With SSP enabled by default these board have insufficient memory for this test.
4f8f280
to
592eb0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So do we want this by default?
For Maybe with the efforts on integrating KConfig we can have a Traditionally we did put such features under |
Here is my
Without SSP:
I also get
Again: This is not a development feature. This is an essential protection mechanism for system security. As such, it helps protecting against exploitation of issue like #10739 and #12905. Please read the original PR text on why it is important to enable by default. From the mechanisms usually employed on constrained operating systems this is the one with the most minimal overhead in terms of binary size. If you are not even willing to enable this one by default I don't see how you want to fulfill the "raising high demand for security and privacy of systems and applications" in the Internet of Things [1, p. 3]. |
ssp breaks LTO on cortexm:
|
How do I reproduce this? Doesn't seem to cause an issue on the builders, builders only fails due to some makefile sanitycheck. Do you want me to adjust that check script accordingly by the way? Also: This doesn't seem to be the only open issue with LTO and cortexm (#5775, #5774, …). Without having investigated this further, it would of cause be possible to (temporarily) disable SSP when using LTO on cortexm. However, if you are not interested in enabling this by default anyhow it doesn't make much sense for me to invest more time in this PR. |
IMO But this raises for me the question, if we build An alternative we could have is enable it as default except for all applications furnished in RIOT, meaning
This for me raises a different very important question, how do we distinguish We can certainly improve this part, there is no clear guide on what is safe to use, and what is just OK for local experimentation, but AFAIK it is something that is being worked on. But we could non the less start documenting this, and make it easy for a novice to grasp what he can easily do. |
RIOT applications are not necessarily networked. Enabling it by default for the network examples makes sense - the if networking then use ssp requirement might be easier to fulfill with the upcoming KConfig though. |
There is nothing prevent application developers from removing SSP from |
Easy, just collecting information / side effects. |
To give some perspective on the size overhead of this change. The following table compares the size of the text segment, with and without the SSP module, of all example applications available on The change, of cause, also has a potential impact on stack space as instrumented function will require additional stack space for the canary value + potential alignment. However, RIOT currently does not seem to employ any technique for determining the current maximum stack usage. Since most threads seem to use macro such as |
ifneq (,$(filter ssp,$(FEATURES_PROVIDED))) | ||
DEFAULT_MODULE += ssp | ||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use FEATURES_OPTIONAL += ssp
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DEFAULT_MODULE
s can be disabled via DISABLE_MODULE
, I think that's not possible with features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can, using FEATURES_BLACKLIST += <FEATURE_TO_BLACKLIST>
;-)
Contribution description
The RIOT website describes RIOT as the "friendly Operating System for
the Internet of Things" and further claims that it is "Developer
Friendly" [1]. Scientific publications, linked on the
website, acknowledge a "raising high demand for security and privacy of
systems and applications" in the Internet of Things. Additionally, the
cited publication claims that "the sheer number of deployed IoT devices
poses a severe threat to the general Internet infrastructure" [2].
Regarding this emphasize on security it seems surprising that RIOT does
not come with any system security features enabled by default. This is
also in contrast to the developer friendlyness mentioned above as it
requires novice users to become security experts, investigate on their
own which security features are available, and manually enable them.
To improve this situation this PR enables a central system security
feature (stack smash protections) by default. While the current
implementation isn't perfect (see #13119) it is still better than having
no stack smash protections at all. Since the current implementation
generates the canary value at compile time the introduced overhead is
minimal. I did some experiments with
BOARD=pba-d-01-kw2x
and changes inbinary size are minimal, e.g.
~1.5KiB
withexamples/dtls-echo
.The change has an additional impact on
runtime memory consumption, however, currently stack
canaries are only added to functions "with buffers larger than 8 bytes".
As such, the overhead is deemed negligible. If you have any tooling to
investigate runtime memory consumption further let me know.
Since the current SSP implementation does have an impact on reproducible
builds it can be disabled explicitly using the
RIOTINSECURE
environment variable.Testing procedure
sys/ssp
is included in the output.RIOTINSECURE=1
check thatsys/ssp
is not included in the output.Issues/PRs references
CC: @kaspar030