-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Indirect branch tracking #13665
Comments
It says that indirect branch tracking is already on by default unless there is an opt-out linker flag, so do we actually need to do anything? |
Yes, the opt-out is temporary. |
OpenBSD enforces it now and Crystal has been marked as broken |
I'd like to help get Crystal supported on OpenBSD, what work needs to be done in order to get IBT support? I'm not sure where to start. |
@joshturge maybe check out QBE's implementation Note that it was reverted due to tooling reasons, but I am trying to do a roll-forward since the blocker seems gone. UPDATE: or, call linker with |
We need to tell LLVM to generate the correct instructions on the x86_64 and aarch64 targets —in gcc/clang this is the I understand we also need to fix the fiber context switch asm for x86_64 and aarch64 to have these too, so we start & resume a fiber? |
OpenBSD 7.4+ enforces Indirect Branch Tracking but we're not yet compatible in Crystal, so we disable the feature for the time being.
Searching for examples, I found out that Rust adds the See the source code and Rust book. |
The Looking at the disassembly of a compiled C program, the x86 option starts all functions with There are more specific values to each option, to enable more features. See the links above for details. I don't know about their impact on the ASM of fiber context switches. They're not needed to support OpenBSD; in fact IBT/BTI isn't needed and we could keep it disabled, but it's interesting to follow on the security and see & measure the impact. |
Initial attempt: c973b01 It only works with I also didn't test fibers. Only a few test files from nanolib and they didn't fail on OpenBSD 🤞 |
OpenBSD 7.4+ enforces Indirect Branch Tracking but we're not yet compatible in Crystal, so we disable the feature for the time being.
Fixes compatibility with OpenBSD 7.4 that enforced indirect branch tracking by default but we're not compatible yet (see #13665), so we must disable it. With this patch I can run the std specs, except for the SSL specs because of openssl/libressl mess, as well as the compiler specs, except for the interpreter specs that regularly crash with SIGABRT (may help to debug issues in the interpreter). Note: the segfault handler is broken on OpenBSD and processes eventually crash with SIGILL after receiving SIGSEGV.
OpenBSD now enforces indirect branch tracking (BTI on arm64, IBT on x86_64) which breaks Crystal on OpenBSD going forward.
I'm not sure whether this would all be handled by llvm and Crystal's compiler just needs to turn it on (in clang it's
-fcf-protection=branch
) or if there is assembly in Crystal that needs to be modified with the new instructions.The text was updated successfully, but these errors were encountered: