Commit Graph

187 Commits

Author SHA1 Message Date
Lakr
4c0430f63e Update .gitignore 2026-03-06 02:50:33 +08:00
Lakr
5388e0c9c5 Squash merge startup-hang-fix into main
Prefix research patch comparison doc and normalize root markdown names

Rename research root markdown files to scoped topic names
2026-03-06 02:42:12 +08:00
zqxwce
4cdff73e8c Merge pull request #112 from zqxwce/bugfix/debugserver-already-resigned
dev_mode: Fix exit if debugserver already patched
2026-03-06 00:01:58 +08:00
zqxwce
8e9aba1224 Merge pull request #111 from zqxwce/feature/amfidont_readme
readme: Add `amfidont` as an option
2026-03-06 00:01:32 +08:00
TastyHeadphones
018b54fb94 Merge pull request #110 from TastyHeadphones/codex/control-request-timeout-cancel
Add request timeout and cancellation handling in VPhoneControl
2026-03-06 00:00:21 +08:00
Lakr
84cc863b5d Merge pull request #108 from zqxwce/feature/entitlements-debugserver
dev_mode: Patch entitlements for debugserver
2026-03-05 18:24:01 +08:00
zqxwce
95a457ce30 dev_mode: Patch entitlements for debugserver 2026-03-05 11:59:46 +02:00
Lakr
7d161d25fc Merge pull request #106 from TastyHeadphones/codex/location-presets-route-replay
Add location presets and route replay controls
2026-03-05 10:24:30 +08:00
Lakr
cb7754334f Merge pull request #105 from McNight/fix/file-transfer-error-alert
fix: show alert on file transfer failure in File Browser
2026-03-05 10:24:19 +08:00
tastyheadphones
fc96e4439d research: drop unrelated patch comparison note from PR 2026-03-05 09:34:19 +09:00
tastyheadphones
596083f30f location: add presets and route replay controls 2026-03-05 09:31:06 +09:00
McNight
e8cb15fa72 fix: show alert on file transfer failure in File Browser
- Upload errors were silently cleared by refresh() before the alert
  could fire; fix by setting self.error after refresh()
- Unreadable local files were skipped silently; now surfaces an error
- Upload loop continued past failures unlike downloads; now breaks early
- Drag-and-drop with no resolvable URLs was silent; now shows an error

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 00:32:26 +01:00
Lakr
203d1a1e1e Merge branch 'startup-hang-fix' 2026-03-05 03:08:10 +08:00
Lakr
d62174755f Update testing_exec.sh 2026-03-05 03:07:47 +08:00
Lakr
2c65c9e109 Update boot-hang_b19_mount_dounmount_strategy_compare.md 2026-03-05 03:06:39 +08:00
Lakr
6d3331ef37 Merge pull request #104 from Lakr233/startup-hang-fix
Startup hang fix
2026-03-05 03:01:42 +08:00
Lakr
560423e391 Create boot-hang_b19_mount_dounmount_strategy_compare.md 2026-03-05 02:57:54 +08:00
Lakr
4669bfbd17 Update testing_exec.sh
Update testing_exec.sh

Update Makefile
2026-03-05 02:57:49 +08:00
Lakr
ba52c2274f skip C22 2026-03-05 02:08:19 +08:00
Lakr
f16a1eed37 squash: merge work-jb-next into main 2026-03-05 01:58:35 +08:00
Lakr
6d0c2c5261 Merge pull request #103 from Lakr233/work-jb-next
Add kernel GDB debug stub option and validation
2026-03-05 01:08:51 +08:00
Lakr
8545dbd9bb Add kernel GDB debug stub option and validation
Introduce a kernel debug port option and wire it through the CLI and VM configuration. Adds a --kernelDebugPort CLI option (default 5909), a kernelDebugPort field in VPhoneVirtualMachine.Options, and validation (1..65535) that throws VPhoneError.invalidKernelDebugPort on invalid values. Configure the VM to use a fixed host GDB debug stub port when possible (with system-assigned fallback) and print the chosen stub info from the AppDelegate. Also include a small menu styling tweak (comma-style) in VPhoneMenuBattery.
2026-03-05 01:05:14 +08:00
Lakr
fdc3e28ae3 Squash merge JB kernel runtime optimizations and testing workflow 2026-03-05 00:33:18 +08:00
Lakr
89f0f698af Merge pull request #100 from TastyHeadphones/codex/setup-machine-ramdisk-panic-detect
setup_machine: fail early on ramdisk panic while waiting for SSH
2026-03-04 23:19:19 +08:00
Lakr
ce0dfff9c6 Merge pull request #102 from xcxmiku/feature/battery-simulation
Add synthetic battery simulation via Virtualization.framework private…
2026-03-04 23:18:47 +08:00
Lakr
964c7d9cd8 docs: add JB mount failure investigation and link from patch comparison 2026-03-04 22:34:36 +08:00
Lakr
8575bef264 Support ramdisk kernel split and snapshot
Add ramdisk-specific kernel snapshot and build logic so the installer ramdisk can boot with a conservative kernel while the restore target keeps the fully JB-patched kernel. Changes:

- research/patch_comparison_all_variants.md: document the Ramdisk Kernel Split and intent.
- scripts/fw_patch_jb.py: snapshot the base/dev-patched kernel before applying JB extensions (new helper and constants).
- scripts/ramdisk_build.py: build krnl.ramdisk.img4 from the snapshot and krnl.img4 from the restore kernel when a snapshot exists; factor kernel IMG4 creation into build_kernel_img4.
- scripts/ramdisk_send.sh: prefer krnl.ramdisk.img4 when present, falling back to krnl.img4; fail early if no kernel image found.

This improves /dev/disk1s1 remount reliability during CFW/install by keeping the restore kernel JB-patched but booting the installer ramdisk with a more conservative kernel variant.
2026-03-04 22:26:06 +08:00
xcxmiku
872bc98c3a Add synthetic battery simulation via Virtualization.framework private API
Use _VZMacSyntheticBatterySource to inject a virtual power source into the
guest VM. The guest kernel's AppleVirtualPlatformPowerSource driver picks it
up automatically via VirtIO, giving iOS a real battery indicator without any
guest-side changes.

- Default: 100% charge, charging state
- Runtime-adjustable via setBattery(charge:connectivity:)
- Battery menu in menu bar with level presets and charging toggle
2026-03-04 22:25:23 +08:00
Lakr
db5a2886fa Enable A2/C23/C24 JB kernel patches in runtime dispatcher 2026-03-04 22:09:12 +08:00
Lakr
adbb3ec085 Improve remote_mount checks and snapshot selection
Ensure target mountpoint exists and verify mounts succeed in remote_mount across cfw_install scripts: create the directory with mkdir -p, short-circuit if already mounted, attempt mount_apfs, and fail with a clear error if the mount did not occur. Also replace the grep|head pipeline with an awk extraction to safely pick the first com.apple.os.update snapshot when renaming to orig-fs.
2026-03-04 22:06:20 +08:00
Lakr
cb63ffa3b2 Remove temporary testing scripts and Makefile targets
These were used for per-patch kernel JB debugging (C23 bisect,
single-patch boot test, batch testing). No longer needed now that
A2, C23, and C24 are all boot-tested and fixed.
2026-03-04 21:43:02 +08:00
Lakr
abaa039496 Merge branch 'kcp_pt_jb' 2026-03-04 21:41:56 +08:00
Lakr
c9fd521659 Fix C24: patch_kcall10 sysent table base, chained fixup encoding, PAC signing
Three bugs caused NOT_BOOT (timeout):

1. Wrong sysent table base: first _nosys match is entry 428, not entry 0.
   Entry 0 is the indirect syscall handler. Fixed with backward scan.

2. Raw VA written to chained fixup pointer slot: struct.pack("<Q", cave_va)
   corrupts the fixup chain from sysent[439] onward. Fixed with proper
   auth rebase encoding (_encode_chained_auth_ptr).

3. Missing PAC parameters: dispatch uses BLRAA X8, X17 with X17=0xBCAD.
   Chained fixup must encode diversity=0xBCAD, key=IA, addrDiv=0.
   Chain 'next' field preserved from original entry.

Boot-tested OK via testing ramdisk.
2026-03-04 21:41:44 +08:00
Lakr
c74abb9aa3 Merge branch 'kcp_pt_jb' 2026-03-04 21:21:33 +08:00
Lakr
894c2d1551 Fix C23: vnode_getattr string anchor resolved to wrong function (AppleImage4)
Root cause: find_string("vnode_getattr") matched "%s: vnode_getattr: %d"
format string inside an AppleImage4 function. The old code then took that
function as vnode_getattr itself, causing BL to call into AppleImage4 with
wrong arguments → PAC failure on indirect branch at a2+48.

Fix: _find_vnode_getattr_via_string() now scans backward from the string
ref for a BL instruction and extracts its target — the real vnode_getattr
(sub_FFFFFE0007CCD1B4 at foff 0xCC91B4).

Bisection confirmed: variants A (stack frame) and B (+ tpidr_el1) boot OK,
variant C (+ BL vnode_getattr) panics with old resolution, boots OK with fix.

Boot-tested: full C23 patch with corrected vnode_getattr — BOOTS OK.
2026-03-04 21:21:23 +08:00
Lakr
916c9c2168 Fix C23 (WIP): switch from ops table pointer rewrite to inline trampoline
Ops table pointer modification breaks chained fixup integrity in the
fileset kernelcache, causing PAC failures in unrelated kexts (e.g.,
AppleImage4). The fixup diversity (0xEC79) also doesn't match the
dispatch discriminator.

New approach: replace PACIBSP at hook function entry with B cave.
Cave runs relocated PACIBSP, ownership propagation shellcode, then
B hook+4 to resume. Uses only PC-relative branches — no PAC, no
chained fixup modification. Also fixes branch offsets in shellcode
to ensure all registers are properly restored in error/skip paths.
2026-03-04 21:02:03 +08:00
Lakr
64e0b2bc4b Update patch_comparison_all_variants.md 2026-03-04 21:00:37 +08:00
Lakr
3879c703e1 Update patch_hook_cred_label_update_execve.md 2026-03-04 21:00:23 +08:00
Lakr
218d3e0db6 Update patch_hook_cred_label_update_execve.md 2026-03-04 20:59:33 +08:00
Lakr
254a70d210 docs: C24 kcall10 analysis — chained fixup pointer mismatch identified
Sysent table uses arm64e chained fixup pointers but patcher writes raw VAs.
Also missing _munge_wwwwwwww and potential PAC issues with BLR X16.
2026-03-04 20:59:27 +08:00
Lakr
ce852cd2c3 Merge branch 'kcp_pt_jb'
# Conflicts:
#	research/kernel_patch_jb/patch_convert_port_to_map.md
#	scripts/patchers/kernel_jb.py
2026-03-04 20:54:53 +08:00
Lakr
5655fd78d7 Fix B8 convert_port_to_map: was patching PAC check instead of kernel_map guard
Root cause: backward branch search found PAC validation B.EQ (target fell
within error region range) instead of the kernel_map guard B.NE. New approach
walks backward from panic string ADRP to find CMP+B.cond where the branch
goes forward past the panic, then makes it unconditional. Also enables B6
and B8 in find_all(). Boot-tested: PASS.
2026-03-04 20:54:16 +08:00
Lakr
6b44f3299f Fix A2: rewrite AMFI execve kill path patch to target shared epilogue
Old approach patched vnode-type assertion BLs (CBZ→panic). New approach
scans backward from function end for the shared MOV W0,#1 kill return
before the LDP x29,x30 epilogue and changes it to MOV W0,#0. Single
instruction converts all 5+ kill paths to success. Boot-tested OK.
2026-03-04 20:52:02 +08:00
Lakr
d4f3b73b75 Fix B6 proc_security_policy: was stubbing copyio instead of real target
Root cause: "most-called BL target" heuristic in _proc_info picked copyio
(4 calls, 0x28C bytes) over the real _proc_security_policy (2 calls,
0x134 bytes). Lowered size filter threshold from 0x300 to 0x200 to
correctly exclude utility functions like copyio. Boot-tested: PASS.
2026-03-04 20:52:02 +08:00
Lakr
4cfeca3a7e Fix A2: rewrite AMFI execve kill path patch to target shared epilogue
Old approach patched vnode-type assertion BLs (CBZ→panic). New approach
scans backward from function end for the shared MOV W0,#1 kill return
before the LDP x29,x30 epilogue and changes it to MOV W0,#0. Single
instruction converts all 5+ kill paths to success. Boot-tested OK.
2026-03-04 20:43:36 +08:00
Lakr
a3756e29a2 Fix B6 proc_security_policy: was stubbing copyio instead of real target
Root cause: "most-called BL target" heuristic in _proc_info picked copyio
(4 calls, 0x28C bytes) over the real _proc_security_policy (2 calls,
0x134 bytes). Lowered size filter threshold from 0x300 to 0x200 to
correctly exclude utility functions like copyio. Boot-tested: PASS.
2026-03-04 20:42:58 +08:00
Lakr
7daa2c4773 Enable 16 verified kernel JB patches, add per-patch research docs
Batch-tested all 24 kernel JB patches individually:
- 18 enabled: A1,A3,A4,B5,B7,B9-B20,C21,C22
- 3 PANIC: A2, B6 (proc_security_policy), B8 (convert_port_to_map), C23 (hook_cred_label_update_execve)
- 1 NOT_BOOT: C24 (kcall10)

Added research/kernel_patch_jb/ with per-patch analysis notes.
2026-03-04 20:08:00 +08:00
tastyheadphones
7413142f11 setup_machine: fail early on ramdisk panic while waiting for SSH 2026-03-04 21:07:03 +09:00
Lakr
a65758e34c Enable 16 verified kernel JB patches, add batch testing scripts
Batch-tested all 20 B/C kernel JB patches individually:
- 16 BOOT_OK: B5,B7,B9-B20,C21,C22 — now enabled
- 3 PANIC: B6 (proc_security_policy), B8 (convert_port_to_map), C23 (hook_cred_label_update_execve)
- 1 NOT_BOOT: C24 (kcall10) — timed out

New scripts for fast per-patch kernel testing:
- testing_do_save.sh: full pipeline + save base kernel backup
- testing_kernel_patch.py: restore backup + apply single named patch
- testing_do_patch.sh: restore + patch + ramdisk + boot (single patch)
- testing_batch.sh: automated batch test with panic/boot detection
2026-03-04 20:05:29 +08:00
Lakr
352d9f8d74 docs: add per-patch kernel JB analysis notes 2026-03-04 20:05:23 +08:00