arm64: handle inlined kCFI failure reporting - #311
xeropresence wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved critical and moderate findings remain in the arm64 CFI handling.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Extends KernelPatch’s scoped arm64 kCFI bypass to handle inlined failure reporting.
Changes:
- Adds
cfi_handlerinterception with CFI target decoding and validation. - Advances permitted KP/KPM faults while preserving existing hooks.
- Adds fallback setup for required arm64 symbols.
| File | Summary |
|---|---|
kernel/patch/common/secpass.c |
Implements arm64 cfi_handler interception and fallback CFI hook setup. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
24931b2 to
2bac735
Compare
|
@Admirepowered pushed the suggested fix. |
|
i think should use kallsyms_lookup_name_by_suffix to search it?Or it is impossible for LTO to do so? |
kallsyms_lookup_name_by_suffix() would help if LTO only renamed the function, but the issue here is actual inlining. On the tested GrapheneOS kernel, report_cfi_failure still exists as a separate symbol, but the disassembly of cfi_handler shows the failure-reporting logic inlined rather than a call to that symbol. Hooking the standalone function therefore misses this path; suffix lookup would not change that. |

Summary
Extend KernelPatch's existing KP/KPM-only CFI exception policy to the arm64
cfi_handlerentry point. This covers kernels where LTO inlinesreport_cfi_failure, bypassing the existing hook on that function.Problem
On the stock Pixel 8 (
shiba) GrapheneOS2026081300kernel, disassembly ofcfi_handlershows inlined failure reporting instead of a call to the separately emittedreport_cfi_failuresymbol. Hooking the latter therefore does not intercept the actual trap path.Kernel-to-KernelPatch callbacks can still fault under kCFI. Observed paths include directory iteration, RCU reclamation, and
stop_machineduring runtime hook removal. Adding separate typed trampolines at each call site works around the missed interception point but is unnecessary when the existing compatibility policy is applied at the trap handler.Changes
cfi_handlerandarm64_skip_faulting_instructionand install an arm64-only before-hook when both exist.should_cfi_pass()address-range check.DBG_HOOK_HANDLED.report_cfi_failureand legacy__cfi_slowpathhooks, and the currentcfi_bypasscompletion flag.This does not make CFI globally permissive. It retains the existing scoped exception for KernelPatch text, hook memory, and KPM executable memory. No callback allocator, syscall-hook changes, task-observer changes, or persistent preset-layout changes are introduced.
Verification
Built the Android ARM64 payload and
kptoolson this branch.Device testing used all three fixes on KernelPatch
0.13.8, with a Pixel 8 running GrapheneOS2026081300: