-
Notifications
You must be signed in to change notification settings - Fork 138
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
Add branch protection flags #260
Conversation
Signed-off-by: David A. Wheeler <[email protected]>
Signed-off-by: David A. Wheeler <[email protected]>
@eslerm @thomasnyman - what do you think? |
This looks good to me! |
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.
thank you @david-a-wheeler !
docs/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.md
Outdated
Show resolved
Hide resolved
docs/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.md
Outdated
Show resolved
Hide resolved
docs/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.md
Outdated
Show resolved
Hide resolved
docs/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.md
Outdated
Show resolved
Hide resolved
Should there be a separate |
docs/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.md
Outdated
Show resolved
Hide resolved
siddhesh commented yesterday asked:
I disagree. Many projects compile for multiple architectures. Even if they only use one today, they may add another one tomorrow. I think it's safer to enable the hardening flags where you can, even if they don't apply to the architecture you're using today. It hurts nothing. |
Signed-off-by: David A. Wheeler <[email protected]>
I've posted an update that I believe resolves all posted issues. |
I'm not saying we shouldn't recommend the architecture-specific flags in the TL;DR; section, I'm saying that the way it is represented right now is incorrect because it will result in a compiler error on all architectures since the architecture-specific flags are recognized only on the supported target. Maybe something like this instead:
The instructions for both PAC/BTI and SHSTK/IBT are in the NOP space, so they'll work seamlessly even on chips that don't have those features. In fact FWIW, SHSTK only got kernel support in 6.6, so at the moment it's still NOP pretty much everywhere in the Linux world. |
Are you sure? I don't see that behavior. I tried this on both clang and GCC on Mac Intel - including the ARM options - and had no problems. Here's my text Makefile:
|
It might be more accurate to say that these flags mitigate code reuse attacks, rather than branch protections or specifying ROP. -fcfp is not exclusively for branch protection. iiuc, the stronger portion of -fcfp is it's shadow stack protection to prevent ROP, where as the endbranch protection is for COP/JOP. -mbranch-protections' BTI and PAC are both branch specific. |
Ah! My makefile had a bug. Once fixed, I do see clang generating errors for unknown flags. Well, that's annoying. I guess we can list options "per architecture". Frankly the best solution here is something like autoconf, so you can add all the options that work, but not everyone will use autoconf. Is there a better approach? |
Signed-off-by: David A. Wheeler <[email protected]>
I've pulled out the architecture-specific flags. How is this? |
docs/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.md
Outdated
Show resolved
Hide resolved
docs/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.md
Outdated
Show resolved
Hide resolved
docs/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.md
Outdated
Show resolved
Hide resolved
docs/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.md
Outdated
Show resolved
Hide resolved
Signed-off-by: David A. Wheeler <[email protected]>
Signed-off-by: David A. Wheeler <[email protected]>
This fixes a merge conflict. Signed-off-by: David A. Wheeler <[email protected]>
I managed to eliminate the merge conflicts (for the moment). I propose merging this (as it's an improvement), and we can make future changes without fighting as many merge conflicts. |
Signed-off-by: David A. Wheeler <[email protected]>
Per meeting today, we agreed to merge this. |
No description provided.