crystal-lang / crystal

The Crystal Programming Language
https://crystal-lang.org
Apache License 2.0
19.34k stars 1.62k forks source link

Indirect branch tracking #13665

Open jcs opened 1 year ago

jcs commented 1 year ago

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.

HertzDevil commented 1 year ago

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?

jcs commented 1 year ago

Yes, the opt-out is temporary.

GeopJr commented 9 months ago

OpenBSD enforces it now and Crystal has been marked as broken

joshturge commented 7 months ago

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.

wecing commented 5 months ago

@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 -z,nobtcfi (see https://github.com/openbsd/ports/commit/71f21f5bf7fed6ec8faa947b5cda278558c0c8de)