-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Description
Currently, E9Patch will disable all Intel Control-Flow Enforcement Technology (CET) features in the rewritten binary. This is because there are several problems with the interaction of E9Tool/E9Patch and Intel CET, specifically:
Indirect Branch Tracking (IBT):
- E9Patch cannot rewrite the
endbr64instruction. If theendbr64is replaced by a jump-to-trampoline, then an indirect call/jump to this location will fail. E9Tool'sif f() gotoinstrumentation will fail unless thegotohappens to target anendbr64instruction. This is because thegotoinstrumentation is compiled down into an indirect jump in the rewritten binary.
Edit: the indirect jump can use theNOTRACKprefix, which disables IBT for the instruction.
Shadow Stack (SHSTK):
- In trampoline code, E9Patch translates
callinstructions into an explicitpush+jumpcombination. This ensures the "original" return address (i.e., as if the program were uninstrumented) is pushed onto the stack, as opposed to a return address belonging to the trampoline. However, this will break SHSTK since thepush+jumpwill not push anything on to the shadow stack.
Possible Solutions
- Never rewrite/replace
endbr64instructions. Disable CET only ifif f() goto(or other incompatible feature) is used.- Implement
calls ascalls in trampoline code (as a user option). This may break transparency, but most programs do not care.
Intel CET Opportunities
Intel CET also helps the E9Tool/E9Patch toolchain:
- E9Tool's control-flow recovery analysis is more accurate since some indirect jump/call targets are explicitly annotated with the
endbr64instruction. This is already implemented. E9Tool can feasibly detect when an instruction is never a jump/call target. This information could be used by E9Patch to further optimize the coverage/speed of the rewritten binary. For example, if the current instruction cannot be patched and is definitely not a target, then the previous instruction could be patched instead. Similarly, if the next instruction is not a target, it can be overwritten without the need for instruction punning.
Edit: unfortunately this will not work if the program uses theNOTRACKprefix, which seems to be common for things like switches (to avoidendbr64proliferation).
Update (18/06/22): I had overlooked the optional NOTRACK prefix for indirect calls/jumps, so the comment is updated accordingly.
Metadata
Metadata
Assignees
Labels
No labels