Skip to content

fix(recipes/v1_0_2): relocate CAVE_REGION out of __eh_frame#40

Open
tkgstrator wants to merge 3 commits into
developfrom
fix/v1_0_2-cave-region
Open

fix(recipes/v1_0_2): relocate CAVE_REGION out of __eh_frame#40
tkgstrator wants to merge 3 commits into
developfrom
fix/v1_0_2-cave-region

Conversation

@tkgstrator

Copy link
Copy Markdown
Contributor

What

make ipa TARGET_VERSION=1.0.2 crashed with 37 cave was not zero-fill nor the matching payload errors. Root cause: recipes/v1_0_2.py inherited 1.0.1's CAVE_REGION = (0x826A000, 0x826C000), but 1.0.2's UnityFramework __TEXT,__eh_frame grew to 0x81ACE58..0x826F5E8 and now fully covers that range. The DWARF CFI bytes there (0x44 0x0e 0x40 ... = DW_CFA_advance_loc | DW_CFA_def_cfa_offset) triggered the verify-before-write guard.

Relocate CAVE_REGION to 0x8270040..0x8272040 — the verified-zero tail after __oslogstring. 8 KB is plenty for 37 caves. lief confirmed all bytes are zero; B reach from the farthest site (0x6082AC0 → 0x8270040 ≈ 35 MB) is well within AArch64 ±128 MB.

Test plan

make ipa TARGET_VERSION=1.0.2 now completes end-to-end and produces packages/ipa/Kiou-1.0.2-patched.ipa. CI builds the three flavours.

🤖 Generated with Claude Code

1.0.2's __TEXT,__eh_frame grew to 0x81ACE58..0x826F5E8, fully covering
the inherited 1.0.1 CAVE_REGION (0x826A000..0x826C000). Writing caves
there clobbered DWARF CFI bytes and verify_patches refused every site
with 'cave was not zero-fill nor the matching payload'.

Move CAVE_REGION to the verified-zero tail after __oslogstring at
0x8270040..0x8272040 (8 KB; UnityFramework section tail). lief-verified
all-zero; B reach from the farthest site (0x6082AC0) is well within
the +/-128 MB AArch64 limit.

Verified end-to-end: make ipa TARGET_VERSION=1.0.2 now succeeds and
produces Kiou-1.0.2-patched.ipa.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 24, 2026 19:03
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the 1.0.2 recipe’s code-cave allocation region to avoid writing into __TEXT,__eh_frame, preventing patch-time verification failures/crashes when building the patched 1.0.2 IPA.

Changes:

  • Relocates CAVE_REGION for recipes/v1_0_2.py to a verified-zero area outside __eh_frame.
  • Adds inline rationale documenting why the 1.0.1 cave region is invalid for 1.0.2.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread recipes/v1_0_2.py
Comment on lines +12 to +16
# 1.0.1's CAVE_REGION at 0x826A000 was a __TEXT zero-fill area, but in 1.0.2
# __TEXT,__eh_frame grew to 0x81ACE58..0x826F5E8 and now covers that range —
# writing caves there corrupts DWARF CFI. Relocate to the verified-zero tail
# after __oslogstring (0x8270023..0x8274000); 8 KB is plenty for 37 caves.
CAVE_REGION = (0x8270040, 0x8272040)
ENTRY_SLOT_BASE_RVA (0x091E91B8) inherited from 1.0.1 lands in
__DATA,__common in 1.0.2 — that section is pre-initialised, so the
recipe's 32-slot block is non-zero on disk. At runtime an entry cave's
BLR through the slot loads that garbage as a function pointer and
crashes (Login, AccountExists, ...).

Relocate to the verified-zero tail of __DATA,__bss at 0x8F9D3B8
(0x100 = 32 slots * 8 B, fits ahead of PROBED_HOOK_SLOT_RVA). bss is
guaranteed zero on launch, so cave -> BLR through an unpublished slot
is harmless until the dylib publishes the hook fn ptr.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants