llvm / llvm/llvm-project

[BOLT] Gadget scanner: make it possible to scan for LR being completely unchecked before tail call

Open
#186,204 2 comments 0 reactions 1 assignee Claimed by @atrosinenko View on GitHub
BOLT
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Presently, PtrAuth gadget scanner implemented as part of `llvm-bolt-binary-analysis` is able to scan for LR being *untrusted* when tail call is performed (which implies explicit checking unless `FEAT_FPAC` is known to be implemented by the CPU). While the AArch64 backend in LLVM has an option to emit explicit pointer check for LR to be authenticated successfully, this instruction sequence is kind of performance vs. security trade-off. On the other hand, even if no explicit pointer check sequence is to be emitted, failure to at least *authenticate* the LR that was reloaded from the stack in epilogue is basically as bad as failure to apply pac-ret hardening to any other function.

It should be an option to check that LR is *safe-to-dereference* (in terms of PtrAuth gadget scanner) before performing a tail call. It should probably be enabled by default as long as pac-ret detector itself is enabled. Though, it still may be reasonable for this option to be controlled independently, as unlike regular return instructions, "tail call returns" are technically just branch instructions and thus require heuristics to be detected.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.