crystal icon indicating copy to clipboard operation
crystal copied to clipboard

Indirect branch tracking

Open jcs opened this issue 10 months ago • 5 comments

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.

jcs avatar Jul 14 '23 15:07 jcs

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?

HertzDevil avatar Jul 14 '23 15:07 HertzDevil

Yes, the opt-out is temporary.

jcs avatar Jul 14 '23 15:07 jcs

OpenBSD enforces it now and Crystal has been marked as broken

GeopJr avatar Nov 29 '23 10:11 GeopJr

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 avatar Feb 22 '24 10:02 joshturge

@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)

wecing avatar Apr 19 '24 13:04 wecing