/* ============================================================================ * HOST REACHABILITY (RAS TA) * * host: INVOKE_CMD { session_id = , ta_cmd_id = N }, no buf_list. * Shared buffer = the LOAD_TA cmd_buf -> HOST VRAM, fully attacker-controlled. * * sub_402B10 (dispatcher) obtains the buffer via sub_402ED0: * v6 = sub_402ED0(paramTypes, params, &idx) * - walks 4 nibbles of paramTypes; requires nibble-5 in {5,6,7} * - requires params[N].size >= 0x828 * - returns params[N].buffer <- shm base (HOST VRAM) * NOTE: if all four nibbles are 0 it falls through with v3=16 and reads * params[4], one element PAST the 4-entry array. NOT reachable: paramTypes * is hardcoded by sOS (proven on hardware -- buf_list num_desc 0..8 gives * byte-identical behaviour), so the host cannot zero the nibbles. * * Also requires *off_402BD0 != 0 ("RAS TA not initialised" otherwise); this * flag is set during LOAD_TA, so it is satisfied for us. * * Layout: * shm+0x00 = command id (v8[0], switch selector) * shm+0x04 = resp_id OUTPUT (v8[1] = cmd | 0x80000000) * shm+0x08 = status OUTPUT (v8[2]) * shm+0x0C = 0 OUTPUT (v8[3]) * shm+0x10 = input struct (handlers receive v8 + 4) * ==========================================================================*/ /* RAS COMMAND 4 -- cmd4 * handler: sub_4038AC @ 0x4038ac * * CONTROLLED INPUT: * shm+0x10 onwards (handler arg = shm+0x10), fully attacker-controlled. * Hardware-measured: only commands 0 and 1 are live on this part; * 2/3/4 return without touching the input. */ int sub_4038AC() { int (*v0)(void); // r1 v0 = (int (*)(void))off_403A60[23]; if ( v0 != nullptr ) return v0(); else return 40976; }