RFC arm64: Make the kprobes debug exception path noinstr
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest9 patches 20 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/9 | arm64/entry: Bound certain debug exception paths in instrumentation windowsarch/ | +17 | 2 replies | |
| 2/9 | arm64/entry: Make debug_exception_enter/exit() noinstrarch/ | +15 | 1 reply | |
| 3/9 | arm64/debug-monitors: Make do_el1_brk64()/do_el1_softstep() noinstrarch/ | +41 | 2 replies | |
| 4/9 | arm64/kprobes: Make the single-step machinery noinstrarch/ | +24 | 3 replies | |
| 5/9 | arm64/kprobes: Invoke pre/post handlers inside instrumentationarch/ arch/ | +21 | 2 replies | |
| 6/9 | arm64/kprobes: Make kprobe_fault_handler() noinstrarch/ | +1 | 2 replies | |
| 7/9 | arm64/kprobes: Drop the KPROBE_HIT_SS reentry special casearch/ arch/ | +1 | 0 replies | |
| 8/9 | arm64/kprobes: Drop the XOL single-step fault PC checkarch/ | +0 | 1 reply | |
| 9/9 | arm64/debug: Mark debug exception helpers __always_inlinearch/ arch/ arch/ +3 more | +11 | 7 replies |
Reviews trailers per patch
1 of 9 patches has a Reviewed-by or Acked-by.
| Patch | Masami Hiramatsu (Google) |
|---|---|
| 1/9 | |
| 2/9 | |
| 3/9 | |
| 4/9 | |
| 5/9 | |
| 6/9 | |
| 7/9 | |
| 8/9 | |
| 9/9 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [RFC PATCH 0/9] arm64: Make the kprobes debug exception path noinstr
From: Hongyan Xia <[email protected]>
Commit 879a6754d3d1 ("arm64: kprobes: Only handle faults originating from XOL slot") and 23f851ac0078 ("arm64: kprobes: Allow reentering kprobes while single-stepping") band-aided two corner cases in the arm64 kprobe path: Unrelated page faults inside Kprobe and nested Kprobe SS handling. Although the two patches were taken, Will asked whether we should keep patching things like this each time we find a corner case, and whether making Kprobe noinstr is the correct answer [1].
This series attempts to do exactly that: Making the Kprobe path noinstr. The kprobe handlers become noinstr end to end, and everything that is inherently instrumentable is confined to instrumentation_begin/end() windows, similar to the x86 side. After this series, the two corner-cases mentioned above are also gone, hence the revert in 7/9 and 8/9. Some of the instrumentation_begin/end() sections are suggested by AI, so they may need careful review.
Note that arm64 has no objtool to validate noinstr, so I wrote a small script finding bl/blr and validated that their calls are confined within noinstr. This is exactly what found the Clang outline compile problem that motivated patch 9/9.
One question is whether other BRK paths get the same treatment. Currently they stay instrumentable inside a big window.
[1] https://lore.kernel.org/all/alpuL10h7-OK2hFb@willie-the-truck/
Hongyan Xia (9):
arm64/entry: Bound certain debug exception paths in instrumentation
windows
arm64/entry: Make debug_exception_enter/exit() noinstr arm64/debug-monitors: Make do_el1_brk64()/do_el1_softstep() noinstr arm64/kprobes: Make the single-step machinery noinstr arm64/kprobes: Invoke pre/post handlers inside instrumentation arm64/kprobes: Make kprobe_fault_handler() noinstr arm64/kprobes: Drop the KPROBE_HIT_SS reentry special case arm64/kprobes: Drop the XOL single-step fault PC check arm64/debug: Mark debug exception helpers __always_inline
arch/arm64/include/asm/esr.h | 2 +- arch/arm64/include/asm/kprobes.h | 15 +---- arch/arm64/include/asm/percpu.h | 2 +- arch/arm64/include/asm/preempt.h | 4 +- arch/arm64/include/asm/ptrace.h | 4 +- arch/arm64/kernel/debug-monitors.c | 76 ++++++++++++----------- arch/arm64/kernel/entry-common.c | 43 +++++++++---- arch/arm64/kernel/probes/kprobes.c | 96 ++++++++++++++---------------- include/linux/kprobes.h | 8 +-- 9 files changed, 131 insertions(+), 119 deletions(-)
Signature · 1 line
2.47.3