1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
|
# Host-reachable attack surface — AMD PSP on Navi 31 (gfx1100)
Scope: everything a host with MMIO access to the GPU can drive on the PSP, measured
on a live 7900XTX (tinygrad AM driver, PCIe over a USB4/ASM2464PD bridge).
Firmware: `psp_13_0_0_sos.bin` 0.49.0.54, `psp_13_0_0_ta.bin` (ASD 33.0.1.21,
HDCP 23.0.0.82, RAS 27.0.2.5, DTM 18.0.0.30).
All status codes below are **measured**, not inferred. Method: submit the command
over the PSP GFX ring, then read the response the PSP writes back into the command
buffer in VRAM (status at `+0x360`, uresp at `+0x3a0`).
--------------------------------------------------------------------------------
## Layer 0 — the transport
host -> BAR5 MMIO -> PSP GFX ring buffer (64 KB, addr from C2PMSG_69/70)
-> psp_gfx_cmd_resp (1024 B) in VRAM
-> PSP writes status back at +0x360 / uresp at +0x3a0
Ring doorbell/wptr: `C2PMSG_67`. Ring control: `C2PMSG_64`. Liveness: `C2PMSG_81`
(free-running ~155 Hz software counter; freezes if the PSP faults).
**Critical constraint discovered:** on this backend `psp.msg1` lives in *system
memory* (`alloc_sysmem`, `AddrSpace.SYS`). The PSP rejects TA images staged there
(constant `0x34`). TA payloads must be staged in **VRAM** (`mm.palloc` +
`paddr2mc`). This was the sole blocker on the whole TA layer.
--------------------------------------------------------------------------------
## Layer 1 — GFX ring commands
Full 256-id sweep. **24 implemented** (+ `0x07` known-implemented, skipped as it
destroys the live TMR) — **231 rejected** with a uniform `0x100`.
cmd status name notes
0x01 0x5 LOAD_TA WORKS with VRAM staging
0x02 0x0 UNLOAD_TA
0x03 0x117 INVOKE_CMD WORKS -> reaches TA code
0x04 0x5 LOAD_ASD WORKS with VRAM staging
0x05 0xffff0007 SETUP_TMR state-gated (0xffff0006 pre-TMR)
0x06 0xffff0010 LOAD_IP_FW param-validated, see below
0x07 0x0 DESTROY_TMR ACCEPTED -> wedges the GPU (DoS)
0x08 0xffff0006 SAVE_RESTORE
0x09 0xffff000a SETUP_VMR
0x0a 0xffff000a DESTROY_VMR
0x0b 0x124 PROG_REG whitelisted, see below
0x0c 0x0 ** UNDOCUMENTED ** word0 bound <4, word1 bound <0xF
0x0d 0x0 ** UNDOCUMENTED ** word0 bound <0xF (VFID)
0x0e 0x4 ** UNDOCUMENTED **
0x0f 0x0 GET_FW_ATTESTATION returns a real 64-bit DB pointer
0x12 0x0 ** UNDOCUMENTED ** NO parameter validation
0x13 0xffff0010 ** UNDOCUMENTED **
0x20 0xffff0010 LOAD_TOC
0x21 0x0 AUTOLOAD_RLC
0x22 0x80000310 BOOT_CFG
0x23 0x1 ** UNDOCUMENTED **
0x24 0x0 ** UNDOCUMENTED ** NO parameter validation
0x25 0x2f ** UNDOCUMENTED ** param- and state-independent
0x26 0xffff0007 ** UNDOCUMENTED **
0x30 0x0 ** UNDOCUMENTED ** NO parameter validation
`0x27 SRIOV_SPATIAL_PART` is documented in amdgpu but returns `0x100` here — not
implemented on consumer Navi 31.
**10 undocumented commands** absent from amdgpu's `psp_gfx_if.h`. Five accept
all-zero parameters and return success (`0x0c 0x0d 0x12 0x24 0x30`).
Error-code families (two-stage validation, confirmed): `0x100` = unknown command
id (bit31 clear, rejected by the dispatcher); `0x8000xxxx` = known command, bad
parameters (bit31 set); `0xffff00xx` = SYS_DRV's internal error vocabulary
(339 occurrences in SYS_DRV vs 9 in sOS).
### Parameter surfaces actually characterised
`LOAD_IP_FW (0x06)` — handler located and **confirmed by hardware prediction**
(`gfx_cmd_LOAD_IP_FW_handler` @ `0xE12D80`, SYS_DRV), 9/10 predictions:
fw_type >= 0x62 -> 0x8000030A
fw_type not in {49,50,85} && size<=0xFF -> 0xFFFF0010
size > 0xFF -> passes into firmware-load code,
hangs the PSP (needs PCIe power cycle)
Downstream, `psp_map_host_phys_range` (`0xE086FC`) maps an attacker-supplied
64-bit physical address. It has an integer-overflow check and a 2^48/64 KB-align
check, but the PF path **skips** `vf_phys_range_check` entirely. Unchanged across
all 8 shipped versions, so intentional (the PF is trusted for addressing).
`PROG_REG (0x0b)` — handler located and **confirmed** (7/7 predictions,
`gfx_cmd_PROG_REG_regid_switch` @ `0xE1B5B0`). Not an arbitrary register write:
constrained by a 16-row x 6-register whitelist at `PROG_REG_whitelist_16x6`
(`0xE23E1C`), 96 registers in `0x3f920..0x3fa9c`. `reg_id` 3 and 4 return success.
`0x0c` / `0x0d` — bounds established by bisection:
`0x0c` word0 accepts 0..3 (bound 4), word1 accepts 0..0xE; `0x0d` word0 accepts
0..0xE. The `<0xF` + `0xFFFF0006` pair is the VFID signature shared with
`vf_phys_range_check`. Accept path leaks nothing (PSP writes zero bytes back), but
a **timing oracle** separates accept from reject: +0.157 ms, z=12.70, 94.2%
single-sample accuracy (n=120 interleaved). Latency is flat across all indices and
both direction values, so the work is fixed-cost.
`0x12` / `0x24` / `0x30` — accept arbitrary values in all six probed words and are
timing-indistinguishable from an invalid command. Most likely no-ops.
--------------------------------------------------------------------------------
## Layer 2 — the TA layer (the real parser surface)
**Verified working from the host**, all four TAs load and three execute commands:
LOAD_ASD ACCEPTED session=0x0
LOAD_TA(RAS) ACCEPTED session=0x1
LOAD_TA(HDCP) ACCEPTED session=0x2
LOAD_TA(DTM) ACCEPTED session=0x3
INVOKE_CMD reachability (does TA code run?)
RAS cmd=0x0 psp=0x0 shm -> resp_id 0x80000000 TA RESPONDED
HDCP cmd=0x1 psp=0x0 shm -> result 0x4 TA RESPONDED
DTM cmd=0x2 psp=0x0 shm -> result 0x0 TA RESPONDED
ASD cmd=0x160 psp=0x4 (no response) NOT INVOKABLE
Protocol (this cost three wrong attempts to get right):
- the TA's shared memory is the **`cmd_buf` passed at LOAD_TA time**, not a
buffer handed to INVOKE_CMD
- amdgpu's `psp_prep_ta_invoke_cmd_buf` populates **no** `buf_list`; populating
one causes a uniform `0x4` rejection
- the per-TA command id goes in the shared buffer, and `ta_cmd_id` in the
INVOKE_CMD struct
### Per-TA host-reachable command surface
TA base funcs cmds param gate status
RAS 0x400100 98 5 MEMREF 5-7, size >= 0x828 reachable
HDCP 0x400100 102 16 paramTypes&0xF==7, size > 0x2817 reachable
DTM 0x400100 14 3 paramTypes&0xF==7, size >= 0x50 reachable
ASD 0xD00100 1551 53 n/a NOT reachable
Entry dispatch is GlobalPlatform-standard in all four: entry type 5 =
`TA_InvokeCommandEntryPoint(sessionContext, commandID, paramTypes, params)`.
**RAS** — 5 commands (0-4), but only two have non-NULL ops on this ASIC:
`ENABLE_FEATURES` (ops[19] -> `sub_4036E4`) and `TRIGGER_ERROR` (ops[21] ->
`sub_403A64`). ops[20]/[22]/[23] are NULL, which is exactly the measured `0xA010`
for DISABLE/QUERY_BLOCK_INFO/QUERY_SUB_BLOCK_INFO. Both live handlers are tiny
(38 and 50 bytes) and copy fixed sizes. `TRIGGER_ERROR`'s `address` field reaches
an RPC validator (`sub_402A1E`, SVC 0xF2), and register programming uses internal
tables — the address is not attacker-steerable. Measured: block_id must be 0
(`*a1 != 0 -> 40980 = 0xA014`, matching blocks 1-15).
**HDCP** — 16 commands, the largest reachable parser surface. All 16 execute and
return distinct per-command codes. Message dispatch (`sub_402910`) bounds declared
length against remaining space (`v5 <= 544`) and is otherwise well-written; the
`544 - v28` chain is protected by `||` short-circuit. **One bug found here**
(below). Everything past session creation is gated on HDCP2 state, which requires
a DDC display-capability read.
**DTM** — 3 commands (2/3/4). Clean: `v2 > 0x17` bounds check, fixed indices, no
variable-length copies.
**ASD** — 53 commands across 8 families (`0x100-0x10D`, `0x160/0x161`,
`0x180-0x1C0`, `0x200-0x20E`, `0x300-0x309`, `0x402-0x405`, `0x800-0x802`,
`0xFFFF0000-07`), dispatcher `sub_D013B8` (`[R5+0]`=cmd, `[R5+4]`=args). Declares
`amd.dr.driverID` / "AMD-TEE ASD Driver" (driver class, vs the TAs'
`gpd.ta.*` / "Application") and holds 18 distinct syscalls incl. 234 raw-MMIO
call sites. `INVOKE_CMD` returns `0x4` for every id including invalid `0xDEAD`,
with both buffer layouts tried — ASD is driven from inside the TEE, not the host.
--------------------------------------------------------------------------------
## Layer 3 — the C2PMSG_35 mailbox
A second host-writable interface, separate from the ring. Protocol confirmed:
host writes with bit31 clear, firmware replies `status | 0x80000000`.
Full 256-command sweep: **every id returns `0x8000000a`**, `C2PMSG_36` never
changes, zero timeouts. Live responder, empty command table. Not useful surface —
most likely boot-window-only, like SETUP_TMR.
--------------------------------------------------------------------------------
## Bugs found, and their reachability
### 1. HDCP TA `sub_402A88` — stack overflow (host-reachable, display-gated)
`memcpy(stack[268], ctx+0x55, 5*N)` where N is one attacker byte, bounded only by
`a3 == 5*N + 25` with `a3 <= 543` -> N <= 103 -> **515 bytes into 268**. Canary at
offset 272, saved LR at 308; both overwritten with attacker-controlled data
(contents staged from the message body at `0x402cac`).
Reach: `INVOKE_CMD(0xF)` -> `sub_4013B4` -> `sub_4021A0` -> `sub_402910` ->
`sub_402A88` (single-path, xref-verified). Present in 8/9 shipped HDCP versions
including current. Full detail in `VULN-HDCP-TA-STACK-OVERFLOW.md`.
**Blocker:** needs `ctx[0]==2` and `ctx[0x10]==6`; `ctx+16` is populated by
`sub_404358` -> SVC 0xF2 -> display DDC capability read. tinygrad initialises no
display IP (SOC/GMC/IH/PSP/SMU/GFX/SDMA only; zero DCN/DCE/DAL code), so **no
monitor changes this** without porting display-core support.
### 2. ASD `sub_D13340` — global overflow (no display needed, not host-reachable)
Length is re-derived from message contents *after* the bounded first copy:
sub_D01058(v20, a2, a1); // a1 <= 5120 into 5120-byte stack buf: safe
a1 = <24-bit big-endian length from message bytes>; // max 0xFFFFFF
if (a1 < 0x13FC) a1 += 5; // adjusts, never clamps or rejects
sub_D010E0(byte_D1F038, v20, a1); // memcpy into a 5120-byte GLOBAL
`byte_D1F038` .. `dword_D20438` = exactly `0x1400` = 5120 bytes, so the adjacent
length variable is the first thing smashed. Up to ~16 MB OOB write, plus OOB read
far past the 5120-byte stack source.
Reach: ASD command `0x308` (jumptable case 776), args loaded via
`LDM R3, {R0-R3}` from `req[1..4]`. **Not host-invokable** — requires a caller
inside the TEE.
### 3. DESTROY_TMR (ring `0x07`) — unauthenticated DoS
Accepted with zero parameters, returns success, tears down the live 19 MB TMR.
Produces a `SOC21_IH_CLIENTID_VMC` page-fault storm; `mode1_reset` then fails with
`SMU msg 0x2 timeout`. Only a **PCIe power cycle** recovers it.
--------------------------------------------------------------------------------
## Summary of the reachability gap
surface host-reachable display-free bug found
ring commands (25) yes yes DoS only
- LOAD_IP_FW params yes yes hang, no corruption
- PROG_REG yes yes whitelisted, clean
- 5 undocumented (null-ok) yes yes unlocated
RAS TA (5 cmds, 2 live) yes yes none (fixed sizes)
DTM TA (3 cmds) yes yes none (bounded)
HDCP TA (16 cmds) yes NO STACK OVERFLOW
ASD (53 cmds) NO yes GLOBAL OVERFLOW
No bug found that is **both** host-reachable and display-free. The host-facing
surface that is display-free is small and conservatively written; the large
parsers sit behind either display state (HDCP) or a TEE-internal caller (ASD).
### Highest-value unexplored items
1. ~~The five undocumented ring commands accepting null parameters
(`0x0c 0x0d 0x12 0x24 0x30`) — reachable, unvalidated, handlers never located.~~
**RESOLVED — all five located in `tee_cmd_dispatch` @ 0x147C4; see
REVIEW-OPEN-THREADS.md §2. `0x12` is a minor info disclosure (§3). The claim
that `0x24` "returns success" is WRONG — it has no handler and returns 256.**
The timing oracle is the only usable observation channel (PSP writes nothing
back on their accept paths).
2. `LOAD_IP_FW` with `fw_size > 0xFF` — passes validation into firmware-load code
with an attacker-controlled 64-bit physical address, and reliably hangs the
PSP. The hang is uninvestigated; it is the only host-reachable path that
demonstrably reaches deep firmware-loading logic.
3. A proxy path from a reachable TA into an ASD command would convert bug #2 into
a host-reachable one.
--------------------------------------------------------------------------------
## Measurement artifacts
/tmp/ring_sweep.json full 256-id ring sweep (this run)
/tmp/verify_ta_surface.py TA load + invoke verification harness
/tmp/resweep.py ring sweep harness (skips DESTROY_TMR)
/tmp/hdcp_trigger.py HDCP LOAD_TA + per-command probe
/tmp/asd_cmd_probe.py ASD invoke attempt (both layouts)
psp_out/FINDINGS.md firmware/rollback analysis
psp_out/VULN-HDCP-TA-STACK-OVERFLOW.md
psp_out/elf/, versions/, sigs/ binaries, ARM ELF wrappers, version diffs
Card verified healthy after all measurements (sOS alive, TMR 0x1300000,
512x512 fp32 matmul correct).
--------------------------------------------------------------------------------
## APPENDIX: image-parser audit (LOAD_TA / LOAD_ASD / LOAD_IP_FW path)
### Where to look in IDA
Open `psp_out/sos_code.bin.i64` (sOS, base 0x0) — names below are already applied.
0x15800 psp_verify_ps1_image $PS1 image validator
0x16C46 psp_image_hdr_locate thin wrapper -> sub_16C8A with a9 = 0xFFFF
0x16C8A sub_16C8A THE MAPPER (178 B) - maps host phys range
0x16C68 sub_16C68 2nd wrapper -> sub_16C8A (a7=1, VF id passed)
0x126DC crypto_digest32 RPC stub (SVC 0xF2)
0x13448 sub_13448 service dispatcher; case 8 -> verify_ps1_image
0x15898 PS1_MAGIC = 0x31535024
Open `psp_out/sys_drv_code.bin.i64` (SYS_DRV, base 0xE00100):
0xE087E4 sub_E087E4 service entry (magic 4096), calls the dispatcher
0xE105A8 sysdrv_big_dispatch_maybe 223 call targets, 6 switch tables
0xE086FC psp_map_host_phys_range SYS_DRV twin of sub_16C8A
0xE1BA30 vf_phys_range_check per-VF containment, SKIPPED on the PF path
### What the validator actually does
psp_verify_ps1_image(req):
psp_image_hdr_locate(req[3]=addr_hi, req[2]=addr_lo, req[4]=len, ...) // map
if *(u32*)(mapped + 0x10) != 0x31535024 -> 47 // $PS1 magic
SVC 0x6D
crypto_digest32(mapped, req[4], out32, 32, &v13, &v12)
if (!v12 || req[4] < v12) -> 3 // size sanity
### Mapper (sub_16C8A) — audited, no bug found
v14 = (lo + len + 4095) & ~0xFFF // page-rounded end
v15 = lo & ~0xFFF // page-rounded start
if ( (v13:v14) < (v11:v15) ) return 4; // 64-bit INTEGER OVERFLOW CHECK - present
map length = v14 - v15 ; caller gets mapped_ptr + (lo - v15)
if (a9 == 0xFFFF || sub_130FC(a9, hi) == 0) { SVC 0x8B / 0x6B } // map
`psp_image_hdr_locate` always passes `a9 = 0xFFFF`, so the VF containment check is
always skipped on this path. Same design as SYS_DRV's `psp_map_host_phys_range`
(unchanged across all 8 shipped versions => intentional; the PF is trusted for
addressing). The overflow check is correct; the page rounding cannot wrap because
of it.
### Result
`psp_verify_ps1_image` is thin: map, magic-check, delegate. `crypto_digest32` is
an RPC stub. **No bug found in the sOS-side image validation path.**
### HONEST GAP — this audit is NOT complete
The actual TA image *structure* parsing (header sizes/offsets beyond the `$PS1`
magic, component descriptors, load-address handling) happens behind `SVC 0x6D` /
`SVC 0xF2` service calls and in the ring `LOAD_TA` handler, **which was never
located**. Specifically:
- 23 of 25 ring command handlers remain unlocated, including LOAD_TA, LOAD_ASD,
LOAD_TOC and all 10 undocumented commands.
- `sub_E087E4` / `sysdrv_big_dispatch_maybe` is an internal service protocol
(requires magic 4096 in word 0); ring submissions with buf_size = 0 succeed,
so this is NOT the ring dispatcher.
- Consequently the parser that consumes our attacker-controlled TA blob beyond
the magic word is still unaudited.
Also unaudited: RAS `sub_402ED0`'s `params[4]` OOB path was resolved as **not
host-reachable** (buf_list `num_desc` 0..8 produce byte-identical behaviour, so
`paramTypes` is hardcoded by sOS), but the HDCP TA was only scanned for one bug
class (non-constant memcpy size), not for indexing/arithmetic errors.
--------------------------------------------------------------------------------
## RING COMMAND DISPATCHER — LOCATED (supersedes "23 of 25 unlocated" above)
The dispatcher is `sysdrv_big_dispatch_maybe` @ **0xE105A8** (SYS_DRV, 671 basic
blocks). It contains THREE `TBB.W` jump tables selected by an outer condition:
switch @0xe106d2 CMP R1,#8 table @0xe106da 8 cases TIER-1
switch @0xe106e2 CMP R0,#0x10 table @0xe106ea 16 cases TIER-2
switch @0xe106fa CMP R0,#0x24 table @0xe10702 36 cases TIER-3
TBB target = table_addr + 2*byte (i.e. PC+4 base — NOT the instruction address).
Cases whose target is the 0xe113a0 stub are unsupported and return 0x100, which
matches the 231/256 commands measured as 0x100 on hardware.
### TIER-1 = the host-active table (anchored by hardware)
`LOAD_IP_FW` (cmd 6) -> sub_E12D80 was independently CONFIRMED on hardware
earlier (9/10 falsifiable predictions), and tier-1 case 6 resolves to exactly
that. IDA's own jumptable annotations agree (0xe1083c = "case 6").
cmd name case block handler
1 LOAD_TA 0xe10bd2 sub_E116CC <-- TA image loader, audited below
2 UNLOAD_TA 0xe10c16 sub_E146A0
3 INVOKE_CMD 0xe10c26 sub_E0C3B8
4 LOAD_ASD 0xe10c3e sub_E1217C (594 B, parses the ASD image)
5 SETUP_TMR 0xe10c58 sub_E142A0
6 LOAD_IP_FW 0xe10ca0 sub_E12D80 <-- HW-CONFIRMED
7 DESTROY_TMR 0xe10bf4 sub_E11870
Tier-2 / tier-3 tables are in the IDB at the addresses above; tier-3 is the only
one containing LOAD_TOC(32)/AUTOLOAD_RLC(33)/BOOT_CFG(34), which were measured as
implemented -- so the outer tier selector is NOT yet understood. UNRESOLVED.
### LOAD_TA handler `sub_E116CC` — audited
Argument struct: the dispatcher sets `R7 = R4 + 0x38` (0xe1062a), so
a1+0x00 = [R5+0] a1+0x08 = [R5+4] << 3
a1+0x04 = ctx+0x3C a1+0x0C = [R5+8]
Entry check (0xe116d2..): bytes at a1+0x0C/0x10/0x14 must have the low 5 bits
clear (32-byte alignment) else return 0xFFFF0006.
Then:
v10 = *(u32*)(a1+8) >> 3; // = ([R5+4] << 3) >> 3 = x & 0x1FFFFFFF
if (*(u32*)(a1+4) != 0)
*(u32*)(base + 0x200) = *(u32*)a1; // store pointer
else
for (i = 0; i < v10; ++i) // REVERSE byte copy
*(u8*)(base + 0x200 + i) = *(u8*)(*(u32*)a1 + v10 - i - 1);
where `base = *off_E257D8`.
CORRECTION: the Hex-Rays output renders the destination as absolute `512+i`
(`MEMORY[0x200]`). The disassembly shows it is BASE-RELATIVE:
0xe11718 LDR R2,[R2] ; R2 = *off_E257D8
0xe11726 ADDS R7,R2,R0 ; R7 = base + i
0xe1172a STRB.W R3,[R7,#0x200] ; base + 0x200 + i
So it does NOT write sOS's vector table. Do not trust the decompiler here.
### Status of the loop: SUSPICIOUS, NOT PROVEN
For:
- the loop count is a host-supplied dword masked to 29 bits (max 0x1FFFFFFF);
- there is NO bound check on it inside sub_E116CC;
- the reverse byte order + `>>3` is the signature of loading a big-endian
crypto modulus/key, so `base+0x200` is likely a fixed 256/512-byte key slot.
Against / unknown:
- `off_E257D8` is read by ~30 functions but NEVER stored in this image (it is
zero-filled BSS initialised outside SYS_DRV), so the destination buffer size
could NOT be determined statically;
- the loop only runs when ctx+0x3C == 0, and the LOAD_TA case does not set
ctx+0x3C;
- which HOST field maps to [R5+4] is unresolved, because sub_E087E4 (magic
4096) shows there is a translation layer between the wire-format
psp_gfx_cmd_load_ta and this internal struct.
=> NOT a confirmed vulnerability. Decisive next experiment: on hardware, hold a
valid TA image constant and perturb LOAD_TA fields one at a time, watching for a
change in error code or a PSP hang, to identify which wire field reaches [R5+4].
--------------------------------------------------------------------------------
## HARDWARE RESULT: the sub_E116CC loop lead is REFUTED
Two experiments were run against the live card.
### 1. Field-mapping test (falsifiable prediction) -- PREDICTION FAILED
sub_E116CC rejects with 0xFFFF0006 unless a1+0x0C/0x10/0x14 are 32-byte aligned.
If R5 were the raw wire psp_gfx_cmd_load_ta, then app_len / cmd_buf_phy_addr_lo /
cmd_buf_phy_addr_hi would have to be 32-byte aligned. Measured:
trial result
baseline (all valid) ACCEPTED sid=0x1
app_len +1 (breaks 32-align) status=0x80000029 <- NOT 0xFFFF0006
app_len +32 (stays aligned) ACCEPTED sid=0x2
cb_lo +1 (breaks 32-align) status=0x6
cb_hi +1 (breaks 32-align) ACCEPTED sid=0x3 <- NOT rejected at all
cb_len +1 status=0x6
app_hi +1 status=0x34
No perturbation produced 0xFFFF0006. => **R5 is NOT the wire struct.** A
translation layer sits in between (consistent with sub_E087E4's magic-4096
protocol). Which wire field reaches [R5+4] could NOT be determined.
### 2. app_len sweep + bisection -- A HARD 1 MB CAP EXISTS
app_len result
0x6100 (real) ACCEPTED
0x16100 (+0x10000) ACCEPTED
0x400000 status=0x5
0x1fffffe0 status=0x5
Bisected (32-byte steps):
max accepted app_len = 0x100000 (exactly 1 MiB)
first rejected = 0x100020
The length is validated against an exact 1 MiB cap, far below the 0x1FFFFFFF the
sub_E116CC loop count could theoretically hold.
### Conclusion
**The unbounded-copy hypothesis is NOT supported.** The only host length field
reaching LOAD_TA is hard-capped at 1 MiB, and the host->internal struct mapping
that would be needed to drive the loop count was falsified by experiment. The
suspicious loop in sub_E116CC is retained in this document as an unproven
observation ONLY; it should not be cited as a vulnerability.
### Incidental (bounded, not security-relevant) observations
- app_len need NOT equal the real image size: values up to the 1 MiB cap are
accepted, so the PSP reads past the image into adjacent host VRAM. That VRAM
is attacker-owned, so this yields nothing.
- cmd_buf_phy_addr_hi +1 was accepted, i.e. the cmd_buf high dword is not
validated the way the app address is. Also attacker-owned memory.
Card verified healthy after every run (sOS alive, TMR 0x1300000, matmul correct).
--------------------------------------------------------------------------------
## TIER SELECTION — SOLVED (mechanism), ring mapping FALSIFIED
### The mechanism (solved)
The three tables are NOT privilege tiers. `sysdrv_big_dispatch_maybe` performs a
BINARY SEARCH on word 0 of its request struct (an internal command id based at
0x1000), and each range gets its own TBB table indexed by the offset from that
range's base:
0xe10620 LDR R3,[R4] ; R3 = internal cmd id
0xe1062e CMP R3,#0x108F BEQ/BGT ; anchors handled by BEQ *before* tables
0xe1065a CMP R3,#0x1019 BGT -> TIER-3 index = R3-0x1019 (36 cases)
0xe10668 CMP R3,#0x1009 BGT -> TIER-2 index = R3-0x1009 (16 cases)
0xe10676 CMP R3,#0x1001 BGT -> TIER-1 index = R3-0x1001 ( 8 cases)
Exact-match anchors dispatch to dedicated handlers, never through a table:
0x1001 -> sub_E09E34 0x1009 -> sub_E09D70 0x1019 -> sub_E1B108
0x103D -> sub_E15BDC 0x108F -> (0xe1072c)
This is why index 0 is the unsupported stub (0xe113a0) in ALL THREE tables: index
0 would mean R3 == the range base, which the BEQ already consumed. That detail
alone confirms the structure.
### TIER-1 index == ring command id (solid)
Three independent semantic anchors:
T1[1] = sub_E116CC parses a $PS1 TA image <-> LOAD_TA (0x01)
T1[4] = sub_E1217C 594 B ASD image parser <-> LOAD_ASD (0x04)
T1[6] = sub_E12D80 HARDWARE-CONFIRMED <-> LOAD_IP_FW (0x06)
### Extending that to TIER-2/3 is WRONG — falsified on hardware
The natural extension `internal = 0x1001 + ring` predicts 57 implemented ring
commands in 0x00..0x3C. Measured on the live card (0x07 skipped: it wedges the
TMR):
implemented (status != 0x100): 24
0x01 0x02 0x03 0x04 0x05 0x06 0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f
0x12 0x13 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x30
unsupported (0x100): 39
24 (+0x07) = 25, matching the original sweep. The map is wrong by more than 2x,
and it mispredicts a specific command:
ring 0x1f map=STUB measured 0x100 AGREE
ring 0x24 map=STUB measured 0x0 *** CONTRADICTION ***
ring 0x2a map=STUB measured 0x100 AGREE
ring 0x34 map=STUB measured 0x100 AGREE
### Conclusion
`sub_E087E4` (word0 must be 4096) is the only caller of the dispatcher inside
SYS_DRV and is itself an unreferenced root -- i.e. it is an ENTRY POINT invoked
from sOS. So SYS_DRV's dispatcher is an internal SERVICE API (57 entries) that
sOS calls with its own internal ids; the GFX ring exposes a 25-command SUBSET,
and the 0x100 "unsupported" responses for the other 231 ring ids are generated by
sOS BEFORE SYS_DRV is ever reached.
Therefore: the ring-id -> internal-id translation lives in sOS, not SYS_DRV, and
is still UNKNOWN except for the tier-1 range where it is the identity.
Only the 7 tier-1 handlers can currently be attributed to ring commands with
confidence. Attributing sub_E07524 to LOAD_TOC, sub_E05140 to BOOT_CFG, etc.
(as an earlier revision of this document did) is NOT supported and is retracted.
--------------------------------------------------------------------------------
## RING -> INTERNAL MAPPING: hypothesis TESTED AND REJECTED
The previous section solved the dispatch MECHANISM. This section tried to pin the
ring-id -> internal-id translation. It failed, and the failure is documented here
so the hypothesis is not resurrected.
### Attempt 1: validity bitmap in sOS -- not found
The 25 implemented ring ids give a unique 8-byte bitmap `fe ff 0c 00 7f 00 01 00`.
Searched sos_code.bin, sys_drv_code.bin and all four TA images for the full
pattern and two sub-patterns. ZERO hits. sOS does not gate the ring with a bitmap.
### Attempt 2: dispatch switch in sOS -- not found
Enumerated every switch in sOS (14 total). Largest is 128 cases at sub_59E8
(low=81); nothing sized for a 0x00..0x3F command space. The two switches whose
DEFAULT case loads 0x100 are sub_147C4 (14 cases) and sub_17B24 (11 cases) --
both too small, and sub_17182's dispatch values (1,5,6,8..24,27,33..40,49,50,57,
58,77,96) are not ring ids.
### Attempt 3: statistical check of `internal = ring + 0x1001` -- UNINFORMATIVE
8 ring commands provably reach SYS_DRV (they return its 0xFFFF00xx error domain).
Under the hypothesis all 8 land on implemented (non-stub) entries: 8/8.
But ~90% of table entries are implemented, so 8/8 has p ~ 0.43 under a random
mapping. This check proves nothing and should not be cited.
### Attempt 4: SHARP test -- HYPOTHESIS REJECTED (1/8)
Does the mapped handler actually CONTAIN the exact error constant the command
returned (searched the handler and one call hop)?
ring measured mapped handler self +callees
0x05 0xffff0007 sub_E142A0 no no
0x06 0xffff0010 sub_E12D80 YES YES
0x08 0xffff0006 sub_E09D70 no no
0x09 0xffff000a sub_E041D4 no no
0x0a 0xffff000a sub_E1BB3C no no
0x13 0xffff0010 sub_E11DC8 no no
0x20 0xffff0010 sub_E07524 no no
0x26 0xffff0007 sub_E137D8 no no
1/8
The ONLY pass is ring 0x06 -> sub_E12D80, which was already established
independently by hardware. The mapping therefore has NO support beyond the single
anchor it was derived from.
Corroborating: 0xFFFF000A occurs at TWO sites INSIDE sysdrv_big_dispatch_maybe
(0xe10626, 0xe106ac). Ring 0x09/0x0a return exactly 0xFFFF000A, which is what a
DISPATCHER-LEVEL REJECT looks like -- i.e. those ids did NOT resolve to the
implemented T2[1]/T2[2] handlers the hypothesis predicts.
### Standing conclusion
SOLVED : the tier/range selection mechanism (binary search + BEQ anchors,
which is why index 0 is the stub in all three tables).
SOLID : ring 0x06 -> sub_E12D80 (hardware, 9/10 predictions).
PLAUSIBLE: ring 0x01 -> sub_E116CC and ring 0x04 -> sub_E1217C, on the semantic
grounds that T1[1] parses a $PS1 TA image and T1[4] is a 594-byte ASD
image parser. NOT independently confirmed.
UNKNOWN : the ring -> internal translation for every other command. It lives in
sOS, and attempts 1-2 failed to locate it.
Handlers attributable to host-reachable ring commands remains 3 (1 confirmed,
2 plausible) -- NOT 7 as an earlier revision of this document stated, and NOT 25.
--------------------------------------------------------------------------------
## PSP CRASH CONTEXT — what exists, and what is unproven
### The firmware DOES capture full CPU context on every fault (certain)
sOS has a complete ARM vector table. Addresses in sos_code.bin.i64:
0x0000 j_vec_reset 0x0098 vec_reset
0x0208 vec_undefined_instruction
0x0240 vec_svc
0x02e4 vec_prefetch_abort
0x0330 vec_data_abort
0x038c vec_irq
0x02b4 (common fault tail)
0x0ee4 fatal_exception_handler
0x80d8 p_exception_stack 0x8178 fault_lr 0xee00 abort_stack_top
Each abort handler saves a FULL register context to *p_exception_stack:
ctx+0x00 R0, R1
ctx+0x08 R2..R14 (saved with STM {R2-LR}^ = the USER bank)
ctx+0x3C faulting PC (LR, pre-adjusted: -8 data abort, -4 prefetch/undef)
ctx+0x40 SPSR (CPSR at fault)
Exception class passed to the handler: 1=prefetch abort, 2=data abort,
3=undefined instruction.
Then `fatal_exception_handler` (0xee4) publishes fault state to MMIO
(base 0x3010000 loaded at 0xf66, and R7=0x3200000 at 0xeee):
STR [0x3010000+0xA48] (zeroed marker)
STR [0x3010000+0xA4C] packed word, see below
STR [0x3010000+0xA50] faulting PC
STR [0x3010000+0xA54] DFSR (data) / IFSR (prefetch) MRC p15,0,c5
STR [0x3010000+0xA58] DFAR (data) / IFAR (prefetch) MRC p15,0,c6 <-- FAULT ADDRESS
STR [0x3010000+0xA60] table value
STR [0x3200000+0x0A8] faulting PC (second copy)
Packed word at +0xA4C is assembled at runtime (0xf04..0xf3e):
class<<28 | tblbyte<<24 | ctx[0x4B]<<16 | (SPSR & 0x1F)<<8 | byte_80FC
i.e. it carries the exception class AND the ARM CPU MODE at fault time.
CORRECTION: an earlier Hex-Rays reading of this function rendered the word as
`(a1<<28)|(loc_55E0<<24)|0xE504FF`, suggesting a fixed 0xE504FF magic. The
disassembly shows there is NO fixed magic -- the decompiler folded symbol
addresses into a constant. Do not use 0xE504FF as a fault signature. (Same class
of decompiler artifact as the `MEMORY[0x200]` misrender in sub_E116CC.)
After publishing, for data aborts (class 2) it loops `cpu_halt_spin()` forever --
which is what a "PSP hang" actually looks like.
### Is that MMIO host-readable? UNPROVEN
Hypothesis: PSP-internal C2PMSG_N == 0x3010A00 + 4N, which would make
+0xA50 = C2PMSG_20 (PC) and +0xA58 = C2PMSG_22 (fault address) -- both readable
from the host.
Host-side plumbing verified working: C2PMSG_N absolute index = 90112+64+N;
reading C2PMSG_32 by that formula matches the named register exactly (0x6aa51d1e).
On a healthy card C2PMSG_14..29 all read 0x0 (clean baseline).
But the hypothesis FAILED its static check: if C2PMSG_0 were at 0x3010A00, sOS
should write its alive marker at displacement 0xB44 (C2PMSG_81, what
`is_sos_alive` reads), and the bootloader-ready flag at 0xA8C (C2PMSG_35).
Scanning every STR/LDR in sOS for those displacements: ZERO sites. Only the
fault handler's own 0xA48/0xA4C/0xA58 appear. So the C2PMSG base is NOT
established and the fault dump may live in PSP-private MMIO.
### Could not test empirically: no crash could be induced
The long-standing note "LOAD_IP_FW with fw_size > 0xFF reliably hangs the PSP"
DOES NOT REPRODUCE. With a valid VRAM address and fw_type=1:
fw_size 0x100 -> 0xffff0008 sOS alive
fw_size 0x1000 -> 0xffff0008 sOS alive
fw_size 0x100000 -> 0xffff0008 sOS alive
fw_size 0x10000000 -> 0x5 sOS alive
fw_size 0xffffffff -> 0x5 sOS alive
No fault, no hang, fault registers stayed 0x0 throughout. That note is RETRACTED.
### Bottom line
If the PSP takes an abort, the firmware definitely records class, CPU mode,
faulting PC, fault-status and fault-address registers. Whether the host can read
them is unresolved. Settling it needs either (a) locating the real C2PMSG base
mapping, or (b) inducing an actual fault and watching for a nonzero value to
appear anywhere in the host-visible C2PMSG window.
--------------------------------------------------------------------------------
## ATTEMPT TO INDUCE A PSP ABORT — 158 trials, ZERO faults
Goal: fault the PSP so `fatal_exception_handler` publishes its dump, then check
whether that dump is visible in the host C2PMSG window.
### Vector 1 — LOAD_IP_FW oversized fw_size (5 trials)
0x100 / 0x1000 / 0x100000 -> 0xffff0008 ; 0x10000000 / 0xffffffff -> 0x5
sOS alive throughout, fault regs stayed 0.
### Vector 2 — $PS1 header corruption (42 trials)
14 size/offset fields (0x14,0x18,0x1c,0x20,0x2c,0x30,0x34,0x58,0x5c,0x68,0x6c,
0x70,0x74,0xcc) x {0xFFFFFFFF, 0x80000000, 0x7FFFFFF0}, on an otherwise valid
RAS image.
ALL 42 -> st=0x34 (uniform clean rejection). sOS alive throughout.
=> the $PS1 header is validated before any field is used. No parse-then-validate
window found.
### Vector 3 — TA shared cmd_buf fuzzing (66 trials)
The shared buffer is NOT signature-checked and is parsed directly by the TA.
Trials: all-0xFF for each RAS cmd id; 0xFFFFFFFF at every 4-byte slot in the
first 128 bytes; 12 fully random 32 KB buffers.
all-FF and length-injection -> OK (handled)
random buffers -> st=0xffff000a
sOS alive throughout, fault regs stayed 0.
=> RAS's input validator (sub_402ED0) is doing its job.
### Vector 4 — undocumented commands with wild parameters (50 trials)
0x0c 0x0d 0x0e 0x12 0x13 0x23 0x24 0x25 0x26 0x30 x 5 payloads
{zeros, all-FF, bad 64-bit ptrs, 0xFFFFFFFF00000000 addrs, unmapped addrs}.
0x0c/0x0d -> 0xffff0006 for every non-zero payload
0x0e -> 0x4 (constant)
0x12/0x24/0x30 -> OK for EVERY payload (they ignore their parameters)
0x13 -> varies (0xffff0010 / 0xffff0006 / 0x5)
0x23 -> 0x1 (constant)
0x25 -> 0x2 (constant for non-zero payloads)
0x26 -> 0xffff0007 (constant)
sOS alive throughout, fault regs stayed 0.
Note: 0x12/0x24/0x30 returning OK regardless of payload means they IGNORE their
parameters entirely -- not that they use them unsafely. An earlier note
describing them as having "zero parameter validation" is misleading and is
corrected here.
### Result
158 trials, 4 vectors, ZERO aborts. Every host-reachable parser tested rejected
malformed input cleanly. Consequently:
- whether the fault dump at 0x3010000+0xA48..0xA60 is readable from the host
REMAINS UNVERIFIED (no fault could be produced to test it);
- as a security result this is a NEGATIVE for the attacker and a POSITIVE for
AMD: the reachable input validation held under every malformed input tried.
### Confirmed host-visible C2PMSG semantics (useful regardless)
C2PMSG_35 0x80000000 bootloader-ready flag (matches _wait_for_bootloader)
C2PMSG_67 steps +0x10 ring pointer, increments per submit
C2PMSG_68 steps +0x10 ring pointer
C2PMSG_81 increments sOS heartbeat (what is_sos_alive reads)
C2PMSG_64 0x80020000 ; 69=0x8a000 ; 70=0x80 ; 71=0x10000 ring config
C2PMSG_14..29 all zero on a healthy card (candidate fault-dump window, never
observed nonzero)
--------------------------------------------------------------------------------
## BOOTING WITHOUT SYS_DRV — sOS does not start, but there is NO observable panic
Tested the recollection that "sOS panics if you don't load SYS_DRV" by patching
AM_PSP.init_hw to load every boot component EXCEPT SYS_DRV (KDB, SPL, SOC_DRV,
INTF_DRV, DBG_DRV, RAS_DRV, SOS), then polling for 6 s. Run twice.
every other component loaded OK
C2PMSG_81 (sOS heartbeat) 0x0 for the full 6 s -> sOS NEVER STARTS
C2PMSG_35 (BL ready) returns to 0x80000000 -> BOOTLOADER STILL READY
C2PMSG_14..29 fault window ALL ZERO
regSCRATCH_REG0..7 ALL ZERO
changed regs in 0..127 only C2PMSG_36/37/38 (the component-load regs)
### Interpretation
The recollection is HALF right. sOS genuinely does not come up without SYS_DRV --
that reproduces cleanly. But it is not an observable panic:
- C2PMSG_35 goes back to BL-ready, i.e. the bootloader is idle and healthy;
- C2PMSG_81 never becomes nonzero, i.e. sOS never executed at all;
- nothing appears in the fault window or in any SCRATCH register.
Best explanation: the BOOTLOADER enforces the SYS_DRV dependency and declines to
launch sOS, rather than sOS running and taking an ARM abort. No exception occurs,
so fatal_exception_handler never runs and no dump is produced.
=> this vector cannot be used to test whether the fault dump is host-readable.
Recovery: a plain `AM_RESET=1` boot restores the card fully (verified twice --
sOS alive, TMR 0x1300000, matmul correct). No PCIe power cycle needed.
### Running total on abort induction
vector trials aborts
LOAD_IP_FW oversized fw_size 5 0
$PS1 header corruption 42 0
TA shared cmd_buf fuzzing 66 0
undocumented cmds, wild parameters 50 0
boot without SYS_DRV 2 0
TOTAL 165 0
The PSP fault-dump path is fully mapped statically (sos 0xee4 and the vector
table at 0x0..0x38c) but has NEVER been observed to fire. Whether its output is
visible from the host remains UNVERIFIED.
--------------------------------------------------------------------------------
## HDCP + DTM SHARED-BUFFER FUZZING (222 trials) — no abort, but surface mapped
Previously only RAS's shared buffer had been fuzzed. HDCP is the largest TA on
the card (28928 B, 16 handlers) and had NEVER been exercised on hardware.
IMPORTANT: the display gate on sub_402A88 (needs ctx[0]==2 && ctx[0x10]==6 via
sub_404358 -> DDC read) gates ONE PATH, not the TA. HDCP loads and all 16 of its
command handlers execute from the host with no display present. An earlier
revision of this document implied HDCP as a whole was display-gated; that is
WRONG and is corrected here.
### Sweep 1 — 190 trials (16 HDCP cmds + 3 DTM cmds x 10 payloads)
payloads: zeros, all-FF, 0xFFFFFFFF injected at offsets 4/8/c/10/14/18, 2x random 32 KB
HDCP cmd 0,8,a,d -> PSP status 0xffff0000
HDCP cmd 1-7,9,b,c,e,f-> PSP status OK
DTM cmd 0,1 -> 0xffff0000 ; cmd 2 -> OK
sOS alive throughout, C2PMSG fault window ALL ZERO.
### Methodology fix
"OK" is only the PSP-LEVEL status (command delivered). The TA writes its own
result INTO the shared buffer, which the first sweep never read back. Re-ran
reading shm[0..7] after each invoke (32 more trials):
every one of the 16 HDCP handlers echoes its cmd id in word 0
and writes a return code in word 1:
cmd 0x1 and 0xe -> 3
all others -> 1
response content differs between a zeros payload and an all-FF payload.
=> all 16 handlers RUN and PARSE our bytes, then reject them with an error code.
Shallow fuzzing bounces off each handler's first parameter check.
### Assessment
HDCP is confirmed host-reachable and live, which makes it the best remaining
target -- it is the only place on the card with an ALREADY-IDENTIFIED overflow
(sub_402A88: memcpy(stack[268], ctx+0x55, 5*N), N<=103 -> 515 bytes, overwrites
canary at +272 and saved LR at +308).
But getting deeper requires knowing each handler's expected input STRUCTURE so
the first validation can be satisfied. That is protocol reverse engineering of
16 handlers, not display plumbing. Both are real work; the protocol route does
not need DCN/DAL and can be done entirely from the existing setup.
### Running total on abort induction
LOAD_IP_FW oversized fw_size 5
$PS1 header corruption 42
TA shared cmd_buf (RAS) 66
undocumented cmds, wild parameters 50
boot without SYS_DRV 2
HDCP + DTM shared cmd_buf 222
TOTAL 387 trials, 0 aborts
--------------------------------------------------------------------------------
## ADDENDUM — why 25 ring ids work despite an 8-entry allow-list
`tee_cmd_dispatch` (sOS `0x147C4`) gates commands with
```c
if ( ring != 0xFFFF && tee_cmd_allowed_on_ring(v6) == 0 ) -> reject
```
where `v6` is the **`cmd_id` field at command-buffer offset 8** (confirmed: the
host struct is `buf_size@0, buf_version@4, cmd_id@8, ..., cmd@28, resp@864`, and
`tee_cmd_dispatch` reads `status` at `dst+8`). `tee_cmd_allowed_on_ring`
(`0x13C7C`) returns 1 for only **{1,2,3,6,9,10,11,33}**.
That allow-list is **not enforced on this hardware.** Two task entry points drive
`tee_ring_drain`, and they pass different `ring` values (5th, stack-passed arg):
| driver | ring value | allow-list |
|---|---|---|
| `bl_legacy_mailbox_loop` (`0x145EC`) | `MOVW R10,#0xFFFF` at `0x14602` | **BYPASSED** |
| `bl_ring_service_loop` (`0x14E88`) | `tee_get_ring_index()`; the `0xFFFF` case branches away at `0x14ECC` without draining | enforced |
`bl_legacy_mailbox_loop` is spawned **unconditionally** (`SVC 0x51` at `0x169F0`);
`bl_ring_service_loop` only when `*(*(0x2060E8+4)+0x234) == 2` (evidently an
SR-IOV/VF configuration, absent on consumer parts). Task entries are stored as
VAs — CODE2 (file `0x12000`) loads at VA `0x200000`, so **VA = FA + 0x1EE000** —
in the table at FA `0x16BE8`/`0x16BEC`.
**Confirmed on hardware:** ring cmd `0x26` returns `0xffff0007`, a **SYS_DRV**
error code (sOS's own families are `0x100` and `0x8000xxxx`), so the command
reached SYS_DRV despite 38 being absent from the allow-list. This explains the
sweep: `0x04 LOAD_ASD` works, `0x07 DESTROY_TMR` wedges the GPU, `0x0F` returns a
real pointer — all outside the allow-list.
**Implication:** the reachable surface is the ~30 SYS_DRV RPCs forwarded by
`tee_cmd_dispatch`, not the 8-command allow-list. The allow-list is effectively
dead code on consumer Navi 31.
### Audit note — `src` vs `dst` (cost two retracted findings)
`tee_cmd_dispatch` snapshots the host buffer (`bl_memcpy(dst, src, 0x400)`) and
passes **`slot`**, which is `dst + 28` (`dst`@`[sp+18h]`, `slot`@`[sp+34h]`), as
the *first* rpc argument. Handlers dereference that first argument. The live
`src+N` pointer is passed as a later argument and is **not** the parsed request.
So repeated loads inside a handler (e.g. `[R6,#8]` six times in
`sysdrv_tee_load_firmware`, `[R4,#4]` twice in `sysdrv_vccc_request`) are
redundant reads of **stack-resident** data, not double-fetches. sOS is using the
correct snapshot-then-parse pattern.
When auditing for TOCTOU here, verify **which argument the handler dereferences**
before concluding anything. See the two RETRACTED docs
(`LEAD-SYSDRV-LOADIPFW-DOUBLEFETCH.md`,
`FINDING-SYSDRV-VCCC-DOUBLEFETCH-UNDERFLOW.md`).
--------------------------------------------------------------------------------
## ADDENDUM — LOAD_IP_FW `fw_type in {49,50,85}`: the size-gate bypass, characterised
Previously flagged as untouched. Now probed on hardware
(`probe_loadipfw_smallsize.py`). **Reachable and confirmed distinct, but no
memory-safety issue found.**
### The gate (`sysdrv_tee_load_firmware` `0xE12D80`)
```asm
0xE12DE4 CMP R5, #0x62 ; fw_type >= 98 -> 0x8000030A
0xE12DEC CMP R5, #0x31 ; 49 \
0xE12DF0 CMP R5, #0x32 ; 50 }-> skip the size check entirely
0xE12DF4 CMP R5, #0x55 ; 85 /
0xE12DF8 LDR R0, [R6,#8] ; else: size must be > 0xFF (a MINIMUM)
0xE12E0A SUBS.W R0, R7, R11,LSR#16 ; R7 - 0xFFFF
0xE12E0E BEQ skip ; ring == 0xFFFF -> SKIP fw_type_is_known
```
Two bypasses, both host-usable: `{49,50,85}` skip the size minimum, and because
the host ring is `0xFFFF` (see the allow-list addendum above) `fw_type_is_known`
is skipped as well — so **any** `fw_type < 0x62` is accepted from the host.
### Hardware results
| fw_type | size=0 | size 0x10 / 0x80 / 0xFF |
|---|---|---|
| **49, 50** | `0x5` | **`0xffff3024`** (not previously seen) |
| **85** | `0x5` | `0xffff0006` |
| 1, 2, 60, 64, 97 (controls) | `0xffff0010` | `0xffff0010` |
Controls are uniformly rejected by the size gate; the three special types are
not, which confirms the bypass empirically. 49/50 and 85 diverge after the map,
so they take different verify paths.
### Why it is not (apparently) a bug
The default path is
`map_client_buffer(addr, [R6,#8])` at `0xE12E68`, whose status is returned
directly — so **`0x5` is simply a zero-length map rejection**, not an
acceptance. For `0x10..0xFF` the map succeeds and execution reaches signature
verification, which rejects the unsigned buffer. All responses returned in
2-3 ms with sOS alive; no fault, no hang.
**CORRECTION (later work).** The interpretation above is **WRONG** for type 85.
`0xffff0006` is not a signature rejection — it is `buffer_copy_bounded`'s own
reject, returned when the element's address is outside `[0x21500,0x21B78]`. This
probe's fill pattern put `0x6f68615a` in the address slot, so the path had
**already reached the register-write loop** and was rejecting our garbage address.
Type 85 never reaches `verify_image_signature` at all.
Re-probed with a valid in-window address (`probe_routec_regwrite.py`): six
rejecting controls reproduce exactly, and address `0x21B40` returns **`0x0`** —
the PSP performs the register write on an unsigned, host-issued command.
See `VULN-LOADIPFW-UNSIGNED-REGWRITE.md`.
**Net: a real, confirmed gate bypass that is ALSO an unsigned register-write
primitive** — not, as originally recorded, a bypass "with no demonstrated
memory-safety consequence".
--------------------------------------------------------------------------------
## C2P mailbox — reachability RESOLVED (corrected encoding), still NOT reachable
The "boot-window-only, most likely" note above was tested properly. Hypothesis:
the prior all-`0x8000000a` sweep wrote raw ids to C2PMSG_35, but the dispatchers
read the command from **BYTE2** (bits 16-23) of the mailbox word — so every
command decoded as 0 -> unknown -> uniform NAK (a plausible false negative).
`probe_c2p_mailbox.py` retested with the id in BYTE2, comparing the ~26 ids the
C2P / mbox dispatchers recognise against 14 unknown ids, and a raw-id control:
raw-id control : all 0x8000000a
KNOWN, BYTE2 : all 0x8000000a (26/26)
UNKNOWN, BYTE2 : all 0x8000000a (14/14)
reply latency : dt = 0.000 (instant) for every id
**Hypothesis FALSIFIED.** BYTE2 encoding changes nothing; known ids are
indistinguishable from unknown; every reply is instant. The instant, uniform NAK
means C2PMSG_35 is answered by a runtime **stub responder** that returns status
`0x0A` ("not supported") for everything — it does NOT feed `bl_c2p_dispatch` /
`bl_psp_mbox_dispatch` at runtime.
The real dispatchers read from the `*(0x2060E4)` mailbox shadow (PSP-internal
memory, not host-writable) and are driven by IRQ/event waits (`SVC 0x5B`). On a
discrete GPU there is no x86 AGESA BIOS to populate that shadow, so the whole C2P
/ AGESA mailbox handler surface (blob load, verify image, key ops, seal config,
SMM lock, PSB directory — ~45 handlers) is **boot-only / vestigial and not
host-reachable at runtime**.
### Consequence — the host-facing attack surface is now fully characterised
Every host-reachable PSP entry point has been enumerated and its handlers
audited:
* **GFX ring / SVC 0xF2 RPCs** — reachable, thoroughly audited, well-defended
(bounded copies, validated buffers, snapshot-then-parse, DACR-confined crypto).
* **INVOKE_CMD to TAs** — HDCP reachable (bugs display-gated / canary-blocked);
ASD rejects host invokes.
* **C2P / AGESA mailbox** — NOT host-reachable at runtime (this section).
* **TMR / trusted DRAM** — hardware-fenced (host reads 0xFF, writes dropped).
No host-reachable-AND-corruptible primitive was found on the current firmware.
The only rollback-exposed issues are DoS-class (TMR range) or near-zero-impact
(CCP guard unreachable by TAs; 4-byte bl_derive_key kernel-stack leak to a TA).
## SMU (MP1) message mailbox — host-reachable, read-only surface AUDITED (clean)
The SMU has its own host-reachable command mailbox (C2PMSG_66/82/90, 79 PPSMC_MSG_*),
reachable over the same register path as everything else (incl. USB4). Audited the
safe read-only surface on hardware (SMU v78.133.0): table DMA is VM-protected (OOB
addr -> VMC page fault -> FAILED, not arbitrary write); index-taking Get* messages
clamp or compute arithmetic (no OOB read); GetVoltageByDpm's unclamped values are a
smooth AVFS formula, not a leak. No disclosure, no arbitrary write on the tractable
surface. Escalation done + negative: (a) TransferTableDram2Smu on safe tables
(ACTIVITY_MONITOR_COEFF/DRIVER_SMU_CONFIG) -> no parser crash; (b) confused-deputy
SMU DMA into the PSP-fenced TMR -> BLOCKED (the fence is requester-agnostic: it
covers the trusted SMU requester too, not just the host BAR path). Only damage-risky
surface left (PPTABLE/OVERDRIVE/I2C table content, resets). See
FINDING-SMU-MAILBOX-HOST-REACHABLE.md + probe_smu_*.py.
|