mirror of
https://github.com/Lakr233/vphone-cli.git
synced 2026-04-05 04:59:05 +08:00
Prefix research patch comparison doc and normalize root markdown names Rename research root markdown files to scoped topic names
4.6 KiB
4.6 KiB
Base Kernel Patch Validation: #11-#15 (Regular + Dev)
Date: 2026-03-05
Scope: non-jailbreak shared kernel patch flow (fw_patch + fw_patch_dev)
Target kernel input: vm/iPhone17,3_26.1_23B85_Restore/kernelcache.research.vphone600
Goal
Validate that base patch items #11-#15:
- hit the intended code paths,
- rewrite the intended instruction shape,
- preserve expected local control flow semantics.
Source-of-truth path
- Regular flow calls
patch_kernelcache()inscripts/fw_patch.py. - Development flow imports and reuses the same
patch_kernelcache()fromscripts/fw_patch.py. KernelPatcher.find_all()order defines patch indices.
Key code references:
scripts/fw_patch.py:235scripts/fw_patch_dev.py:12scripts/patchers/kernel.py:56scripts/patchers/kernel_patch_dyld_policy.pyscripts/patchers/kernel_patch_apfs_graft.pyscripts/patchers/kernel_patch_apfs_mount.py
Verification method
- Load clean IM4P payload from
kernelcache.research.vphone600. - Run
KernelPatcher.find_all()and capture emitted offsets/descriptions. - Compare instruction bytes before/after for #11-#15.
- Assert matcher semantics programmatically:
- dyld patch pair has
BL + conditional-on-w0and distinct BL targets. _apfs_graftBL target equalsvalidate_on_disk_root_hashfunction._apfs_mount_upgrade_checkstarget isBL + TBNZ w0with small leaf callee._handle_fsioc_graftBL target equalsvalidate_payload_and_manifestfunction.
- dyld patch pair has
- Cross-check in IDA:
- patch site belongs to expected function region (string xref/function context).
Results
Base VA: 0xFFFFFE0007004000
#11 patch_check_dyld_policy (@2)
- file offset:
0x016410C8 - VA:
0xFFFFFE00086450C8 - before:
bl #0x1638384 - after:
mov w0, #1 - next instruction (unchanged):
tbnz w0, #0, ... - matcher assertions:
@1and@2are bothBLfollowed by conditional branch onw0: PASS- BL targets are different: PASS
- IDA context:
- site in function
sub_FFFFFE000864507C - same function references string
com.apple.developer.swift-playgrounds-app.development-build
- site in function
#12 patch_apfs_graft
- file offset:
0x0242011C - VA:
0xFFFFFE000942411C - before:
bl #0x246d398 - after:
mov w0, #0 - next instruction:
cbz w0, ... - matcher assertion:
- BL target equals
_find_validate_root_hash_func()result: PASS
- BL target equals
- IDA context:
- site in function
sub_FFFFFE000942326C(apfs_graft call path) - target function aligns with
authenticate_root_hashstring-referenced routine (sub_FFFFFE00094711CC/entry region at0x...9471398)
- site in function
#13 patch_apfs_vfsop_mount_cmp
- file offset:
0x02475044 - VA:
0xFFFFFE0009479044 - before:
cmp x0, x8 - after:
cmp x0, x0 - adjacent shape (before patch):
bl ...adrp x8, ...ldr x8, [x8, ...]ldr x8, [x8]cmp x0, x8b.eq ...
- interpretation: correct hit on mount path thread-vs-kernel-task comparison.
#14 patch_apfs_mount_upgrade_checks
- file offset:
0x02476C00 - VA:
0xFFFFFE000947AC00 - before:
tbnz w0, #0xe, ... - after:
mov w0, #0 - previous instruction:
bl #0xCC6144 - matcher assertion:
- previous BL target behaves as small leaf (ret within first
0x20bytes): PASS
- previous BL target behaves as small leaf (ret within first
- IDA context:
- site in function
sub_FFFFFE000947AB88 - function region references
apfs_mount_upgrade_checks
- site in function
#15 patch_handle_fsioc_graft
- file offset:
0x0248C800 - VA:
0xFFFFFE0009490800 - before:
bl #0x2416bd4 - after:
mov w0, #0 - next instruction:
cbz w0, ... - matcher assertion:
- BL target equals
_find_validate_payload_manifest_func()result: PASS
- BL target equals
- IDA context:
- site in function
sub_FFFFFE000949074C - target function aligns with
validate_payload_and_manifest(sub_FFFFFE000941ABD4)
- site in function
Input consistency note
- VM clean IM4P payload and IDA-loaded macho have same size but different hash.
- Dword diff count is
25, and the diff set includes all expected base patch sites. - This is consistent with IDA sample being the patched image variant for the same kernel.
Conclusion
For kernelcache.research.vphone600 prepared from clean firmware:
- patch #11 (
_check_dyld_policy_internal @2) works and hits intendedBLsite. - patch #12 (
_apfs_graft) works and hits intended validationBLsite. - patch #13 (
_apfs_vfsop_mount cmp) works and hits intended compare site. - patch #14 (
_apfs_mount_upgrade_checks) works and hits intendedTBNZ w0site. - patch #15 (
_handle_fsioc_graft) works and hits intended validationBLsite.
Status: working for now (correct semantic hit + instruction rewrite on this kernel variant).