New code for SIGILL faults to help identify misbranches on OpenBSD
undeadly.org
undeadly.org
https://en.wikipedia.org/wiki/Control-flow_integrity
I guess (although it doesn't specifically say) that this is making use of Intel's CET feature?
https://en.wikipedia.org/wiki/Return-oriented_programming#Br...
That page has a reasonable summary of the exploitation techniques and history motivating this work.
BTW. A similar extension is also about to be approved for RISC-V: "Zicfilp". It also repurposes an instruction that was previously a NOP.
So, ROP itself is a (frequently very effective) workaround for W^X memory protection features, where executable code itself should be unmodifiable at runtime. I wonder if there's a "next" CFI attack that calls existing functions that are actually defined as such, but in a weird order, or with weird arguments.
The ability to do that effectively would depend on lots of stuff, including the calling convention (as the stack or heap are easier to corrupt than registers).
Maybe someone is already writing an advanced ROP gadget-search that looks for "real functions that can be combined to make ROP gadgets by calling them in a bizarre way". (This is already much less likely to occur in a real program ... I think ...! But maybe the return-to-libc phenomenon is still a rich source of vulnerability?)
I'm not sure how or if it addresses trampolines and similar thunks that interpose callee and caller, but which don't necessarily touch arguments. Such thunks are quite common in dynamically linked code as ELF and Mach-O do lazy loading by default--dynamic function symbols are initially small thunks that load the dependency and then forward the call, restoring registers and the stack without having to know the call signature.
The full patch is at https://github.com/openbsd/src/commit/88580652a3669007813512...
I'm not sure if this patch is noteworthy on its own, but perhaps it was posted because it implies this CPU feature is now supported or soon to be supported by OpenBSD.
OpenBSD has supported mandatory BTI/IBT on Intel CPUs (11th Gen+) and arm64 (Apple M2) since 7.4 (Oct 16, 2023).
https://www.openbsd.org/innovations.html
"Mandatory enforcement of indirect branch targets (BTI on arm64, IBT on Intel amd64), unless a linker flag (-Wl,-z,nobtcfi) requests no enforcement."
https://marc.info/?l=openbsd-ports&m=168899645126958&w=2
OpenBSD recently disabled retpolines by default because they are incompatible with IBT, so there has been some work done recently that this patch could help with, e.g: adding missing indirect branch target instructions (endbr64), previously hidden by retpoline. OpenBSD has done a lot of work to push these changes into the entire software ecosystem.
I haven't followed this and surely misrepresent the facts above. This is just a plea for someone in the know to clarify the situation.
How much of a performance flow mitigation is this, 3-5%?
ARM's Pointer Authentication extension is an interesting alternative which does all of this in one feature by cryptographically signing pointers in memory.
Techniques like CHERI could replace MMUs in some environments, potentially improving performance.
You do have to generate correct code but that's actually a solvable problem, web assembly did it.
In theory this could unlock tons of performance (and free up some silicon) if we could ever get the rest of the system away from C