Skip to content

feat: perf KASLR leak (primary), slide as fallback - #30

Merged
Colorful-glassblock merged 7 commits into
mainfrom
feat/perf-kaslr-leak
Jul 25, 2026
Merged

feat: perf KASLR leak (primary), slide as fallback#30
Colorful-glassblock merged 7 commits into
mainfrom
feat/perf-kaslr-leak

Conversation

@Colorful-glassblock

Copy link
Copy Markdown
Owner

Port perf_leak_text_base() from CyberMeowfia PR #36 (Moto G05 MTK).

How it works:

  • Opens perf_event with PERF_TYPE_SOFTWARE + PERF_COUNT_SW_CPU_CLOCK
  • Busy-loop generates kernel IP samples
  • Scans ring buffer, filters via PERF_RECORD_MISC_KERNEL flag
  • Takes minimum kernel IP >= KIMAGE_TEXT_BASE, rounds to 2MB alignment
  • P0_KERNEL_PHYS_DELTA=0 for duchamp, so text_base = min_kip & ~(2MB-1)

Flow: perf leak tries first → if fails, slide leak as fallback

Your device has perf_event_paranoid=-1, so this should work without issues.

root added 7 commits July 21, 2026 03:19
slabinfo shows mm_struct objsize=1024 (0x400), MM_STRUCT_SZ stays 0x400.
KSNITCH_COLLISIONS lowered from 4 to 1 to match device behavior.
Added get_ksnitch_collisions() for runtime override via env var.
The duchamp slide route was missing a consumer thread that calls
sched_setattr_tid() on the waiter thread. Without this, there is no
PI chain formation and the boot_id KASLR leak always fails.

Changes:
- Add slide_consumer_thread() that calls sched_setattr_tid() on the
  waiter thread while it's blocked in pselect
- Launch consumer thread in slide_pselect_stack_copy()
- Remove perf_leak_stext() fallback (untested, unreliable)
- KSNITCH_COLLISIONS lowered to 1 with env var override
Port perf_leak_text_base() from CyberMeowfia PR #36 (Moto G05 MTK).
Uses PERF_TYPE_SOFTWARE + PERF_COUNT_SW_CPU_CLOCK to sample kernel IPs,
takes minimum kernel IP >= KIMAGE_TEXT_BASE, rounds to 2MB alignment.
Your device has perf_event_paranoid=-1 so this should work.

- perf leak tries first, slide leak as fallback
- Busy-loop sampling instead of sleep
- Filters kernel IPs via PERF_RECORD_MISC_KERNEL flag
- P0_KERNEL_PHYS_DELTA is 0 for duchamp, so text_base = min_kip & ~(2MB-1)
@Colorful-glassblock
Colorful-glassblock merged commit 2ae6196 into main Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant