-
Notifications
You must be signed in to change notification settings - Fork 15
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
x86_64: Add CET instructions and check in CI #761
Conversation
0c95f79
to
cb3a0f9
Compare
0b87872
to
851964b
Compare
851964b
to
91f3f99
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.
I would prefer not to dummy-define CET_xxx but use a MLK wrapper. Otherwise we risk breaking this with the undef section in the monobuild
Modern x86_64 support hardware features through the CET instructions to protect against return-oriented programming (ROP) attacks. Those protections can be enabled through -fcf-protection=. For this to work, all compilation units (including assembly) need to support CET. This commit adds support and contains two main changes: 1) Each assembly file needs to set the the appropriate note.gnu.property section to signal that it does support CET. We achieve this by including cet.h in all assembly files which sets the required properties. Note that this applies also to empty compilation units (e.g., the aarch64 assembly files when compiling for x86_64). 2) Each label that can potentially be a target of an indirect branch needs to start with en endbr64 instruction, otherwise the branch faults. Our assembly does not use indirect branches and, hence, any internal branching is unaffected by this. However, the global symbols may potentially be targets of indirect branches (they don't seem to be though). To address this, we add endb64 to every global symbol by using the _CET_ENDBR macro provided by cet.h. Note that this is only adding the instruction in case CET is enabled. We introduce a new macro MLK_ASM_FN_SYMBOL that adds this automatically for X86 systems. This way our assembly simplification scripts are unaffected as the endbr64 instructions are out of scope. Signed-off-by: Matthias J. Kannwischer <[email protected]> .
Signed-off-by: Matthias J. Kannwischer <[email protected]>
This commit adds a workflow that checks if we properly support CET by compiling with -fcf-protection=full. This primarily checks that all assembly compilation units set the required note.gnu.property section signaling CET support (this can be achieved by setting -Wl,-z,cet-report=error). This does _not_ make sure all global symbols have the required endbr64 instructions. Our binaries do not use indirect branches anywhere, so if those instructions would be missing, there would not be any fault. Signed-off-by: Matthias J. Kannwischer <[email protected]>
91f3f99
to
9e9d899
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.
Thank you @mkannwischer !
Modern x86_64 support hardware features through the CET instructions to protect
against return-oriented programming (ROP) attacks. Those protections can be
enabled through -fcf-protection=.
For this to work, all compilation units (including assembly) need to support
CET.
This commit adds support and contains two main changes:
Each assembly file needs to set the the appropriate note.gnu.property
section to signal that it does support CET. We achieve this by including cet.h
in all assembly files which sets the required properties.
Note that this applies also to empty compilation units (e.g., the aarch64
assembly files when compiling for x86_64).
Each label that can potentially be a target of an indirect branch needs
to start with en endbr64 instruction, otherwise the branch faults.
Our assembly does not use indirect branches and, hence, any internal branching
is unaffected by this.
However, the global symbols may potentially be targets of indirect branches
(they don't seem to be though). To address this, we add endb64 to every global
symbol by using the _CET_ENDBR macro provided by cet.h. Note that this is
only adding the instruction in case CET is enabled.
We introduce a new macro MLK_ASM_FN_SYMBOL that adds this automatically for
X86 systems. This way our assembly simplification scripts are unaffected as
the endbr64 instructions are out of scope.
Resolves #762