Skip to content

Commit 7b209a6

Browse files
committed
Update KPM exec free hardening
1 parent ff1156c commit 7b209a6

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
2323
### Changed
2424

2525
1. Bumped the current `main` KPM loader marker to `ReSukiSU-x86_64-KPM-loader/0.21` for the native x86_64 syscall wrapper ABI.
26-
2. Advanced the `KernelSU` submodule from ReSukiSU `a0d26e23` to `79a5ae91`, including hook hardening, native syscall wrappers, Manager guards, CI formatting fixes and module-context ownership hardening.
26+
2. Advanced the `KernelSU` submodule from ReSukiSU `a0d26e23` to `8326d60c`, including hook hardening, native syscall wrappers, Manager guards, CI formatting fixes, module-context ownership hardening and generated exec free cleanup hardening.
2727
3. Expanded release provenance capture with kernel tag, dirty-state flags, Windows build, HVCI state, WSA package metadata, release `ksud` SHA256 and helper-script SHA256 values.
2828
4. Updated README, build, install, FAQ, KPM porting, module compatibility and known-good archive documentation around the `0.20` published loader marker versus the current `0.21` source marker.
2929
5. Updated the WSA compatibility matrix for the local `D:\WSA` install on Windows build `26200` with Memory Integrity enabled.
@@ -38,6 +38,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
3838
4. Stabilized ReSukiSU x86_64 ABI and Manager guard CI paths so local and GitHub runner checks use the same expected inputs.
3939
5. Applied clang-format fixes required by the GitHub runner for the KPM loader sources.
4040
6. Made live selftests stop with a clear installed-userspace mismatch when `/data/adb/ksud` lacks the `kpm` subcommand.
41+
7. Made generated executable memory cleanup fail closed when the final `RW+NX` transition fails before `module_memfree()`.
4142

4243
### Verified
4344

docs/KPM_PORT.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Implemented:
2626
5. x86_64 inline hook backend that uses the kernel `insn` decoder for length and RIP relative fixup.
2727
6. `text_poke_bp()` based install and restore for normal `JMP rel32` hooks under `text_mutex`.
2828
7. `RW+NX` to `ROX` page transitions for trampolines and wrapper stubs.
29-
8. `synchronize_rcu_tasks_rude()` plus `synchronize_rcu_tasks()` before generated executable buffers are freed.
29+
8. `synchronize_rcu_tasks_rude()` plus `synchronize_rcu_tasks()` before generated executable buffers are freed, with free refused if the final `RW+NX` permission transition fails.
3030
9. Refusal of unsafe or conflicting hook targets owned by ftrace, kprobes, alternatives, jump labels or static calls.
3131
10. Refusal of patching from IRQ or atomic context.
3232
11. Native x86_64 syscall-table wrappers through `hook_syscalln`, `fp_wrap_syscalln` and `inline_wrap_syscalln`.
@@ -78,6 +78,7 @@ Restore:
7878
1. The patcher acquires `text_mutex`.
7979
2. `text_poke_bp()` writes the original prologue bytes back. The breakpoint emulation step uses the previous jump bytes so that any in flight CPU continues into the trampoline rather than into a half restored prologue.
8080
3. `synchronize_rcu_tasks_rude()` and `synchronize_rcu_tasks()` are called before the trampoline pages are freed, so no task can still be running inside them.
81+
4. Before `module_memfree()`, generated executable buffers are switched back to `RW+NX`. If that transition fails, the loader logs the failure and keeps the allocation resident instead of freeing pages with stale executable permissions.
8182

8283
Far jump fallback:
8384

@@ -97,6 +98,7 @@ Refusal predicates at install time include:
9798
3. If `.kpm.exit` returns an error, the module remains loaded rather than freeing executable memory that hooks or callbacks may still reference.
9899
4. `ksud kpm` propagates negative kernel return codes as command failures instead of reporting success.
99100
5. `ksud kpm doctor --json` reports loader reachability, module count, safe mode and KPM directory hardening.
101+
6. Generated executable memory free is fail-closed: a failed `RW+NX` transition is treated as a hard cleanup error and the buffer is intentionally retained for diagnosis.
100102

101103
## Manager Packaging
102104

0 commit comments

Comments
 (0)