aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoruser <user@clank>2026-09-30 03:22:57 +0200
committeruser <user@clank>2026-09-30 03:22:57 +0200
commita1da4d5909ac47914f8618bd0c89976ae0600a80 (patch)
tree7bf93b7f6dd1f8a9db26b39228a49d7253ba1a5f
parentindex the hardware probes so they are discoverable and usable (diff)
downloadamd-psp-re-a1da4d5909ac47914f8618bd0c89976ae0600a80.tar.gz
amd-psp-re-a1da4d5909ac47914f8618bd0c89976ae0600a80.tar.xz
amd-psp-re-a1da4d5909ac47914f8618bd0c89976ae0600a80.zip
hundred-and-fourteenth pass: close the last acknowledged weak spot in coverage
An earlier pass recorded its own handle test as weak evidence, since harvested handles were injected at a single offset so a real handle field elsewhere was never exercised and a command ignoring that offset made the control fire vacuously. That was the only row in the coverage table not backed by a discriminating test. The new probe harvests the handles an application emits, invokes every command once so it can free whatever it frees, then replays each handle at every dword offset, each time paired with a random value at the same offset as the discriminator, since an offset accepting the handle while rejecting the random value would be a field that is read and ownership-checked and therefore a use-after-free if the handle was freed first. Across three applications no offset in the swept range accepts a stale handle while rejecting a random value. One application yielded only a single harvested handle, so its row remains thin and that is stated rather than counted as strong. The coverage table now has no row backed only by weak evidence, and the objective is not met.
-rw-r--r--fw/AUDIT-TA-MEMSAFETY-HUNT.md32
-rw-r--r--hw/README-PROBES.md3
-rw-r--r--hw/handle_offsweep.py72
3 files changed, 106 insertions, 1 deletions
diff --git a/fw/AUDIT-TA-MEMSAFETY-HUNT.md b/fw/AUDIT-TA-MEMSAFETY-HUNT.md
index fcd505d..8b6beba 100644
--- a/fw/AUDIT-TA-MEMSAFETY-HUNT.md
+++ b/fw/AUDIT-TA-MEMSAFETY-HUNT.md
@@ -4391,3 +4391,35 @@ defective, and it is also the one that most restricts concurrency.
**Not met.** Slot reuse across sessions — the last structural variant of the axis where this
firmware's only known defects live — is now covered and negative.
+
+================================================================================
+# Hundred-and-fourteenth pass: closing the last acknowledged weak spot
+
+Pass 94 recorded its own handle test as **weak evidence**: harvested handles were injected
+only at offset `+4`, so a real handle field elsewhere in the parameter block was never
+exercised, and a command ignoring `+4` made the control fire vacuously. That row was the only
+one in the coverage table not backed by a discriminating test.
+
+`hw/handle_offsweep.py` fixes it. Handles the TA emits are harvested, every command is then
+invoked once so the TA can free whatever it frees, and each handle is replayed at **every**
+dword offset — each time paired with a **random value at the same offset** as the
+discriminator. An offset where the handle is accepted and the random value rejected would be
+a field that is read and ownership-checked, i.e. a use-after-free if the handle was freed
+first.
+
+| TA | handles harvested | offsets x commands | result |
+|---|---|---|---|
+| GCP | 17 | 400 x 4 | **none** |
+| MERIT | 4 | 300 x 4 | **none** |
+| OPM | 1 | 300 x 4 | **none** |
+
+No offset anywhere in the swept range accepts a stale handle while rejecting a random value.
+OPM's single harvested handle still makes its row thin, and that is stated rather than
+counted as strong.
+
+The coverage table now has **no row backed only by weak evidence**.
+
+## Objective status after a hundred and fourteen passes
+
+**Not met.** The last acknowledged soft spot is closed with a discriminating control. No
+memory-corruption primitive.
diff --git a/hw/README-PROBES.md b/hw/README-PROBES.md
index d714275..d1650d5 100644
--- a/hw/README-PROBES.md
+++ b/hw/README-PROBES.md
@@ -52,7 +52,8 @@ results in the audit log were discarded on exactly that basis.
| `loadta_sweep.py` | full-resolution sweep of the LOAD_TA structure |
| `ta_seqfuzz.py` | stateful sequences: output carried into the next invoke |
| `ta_multisess_seq.py` | multi-session stateful fuzz with slots recycling underneath |
-| `ta_handlefuzz.py` | handle replay — **coarse, weak evidence**, see audit pass 94 |
+| `ta_handlefuzz.py` | handle replay at offset +4 only — **superseded** by `handle_offsweep.py` |
+| `handle_offsweep.py` | handle replay at **every** dword offset, vs a random-value control (closes pass 94's weak spot) |
| `gfx_undoc.py`, `gfx13_probe.py` | the last two unread GFX commands |
## Earlier rounds (GCP lifetime work)
diff --git a/hw/handle_offsweep.py b/hw/handle_offsweep.py
new file mode 100644
index 0000000..14966b8
--- /dev/null
+++ b/hw/handle_offsweep.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python3
+"""Handle replay at EVERY offset — closing the weak spot recorded in audit pass 94.
+
+`ta_handlefuzz.py` injected harvested handles only at offset +4, so a real handle field
+elsewhere was never exercised and its negative was explicitly recorded as weak evidence.
+With the ring ceiling removed, the injection point can be swept across the whole window.
+
+Method: harvest handles the TA emits, then for each dword offset inject (a) a harvested
+handle and (b) a random value, and compare. An offset where the HANDLE is accepted and the
+random value is rejected is a field that is both read and liveness/ownership checked -- and
+if the handle was destroyed first, that is a use-after-free.
+
+Sequence per offset: destroy-ish pass first (invoke every command once to give the TA a
+chance to free things), then replay.
+"""
+import glob, random, struct, sys, time
+sys.path.insert(0,'/root/psp/hw')
+from tinygrad import Device
+import tinygrad.runtime.autogen.am.am as am
+from ring_wrap import install
+adev=Device["AMD"].iface.dev_impl; psp=adev.psp
+submit=install(psp,adev)
+WIN=0x4000
+TAS={'GCP':'ta_22-0-0-77_7c426e7f','MERIT':'ta_24-0-0-70_5cd4afda','OPM':'ta_25-0-0-81_dc596ba6'}
+name=sys.argv[1]; NOFF=int(sys.argv[2]) if len(sys.argv)>2 else 512
+blob=open(glob.glob('/root/psp/contall/'+TAS[name]+'*')[0],'rb').read()
+def alloc(n):
+ pa=adev.mm.palloc(n,align=0x1000,zero=True,boot=False); return pa,adev.paddr2mc(pa)
+ap_,amc=alloc(0x80000); cp,cmc=alloc(0x8000)
+n=(len(blob)+3)&~3
+adev.vram.view(ap_,n)[:]=blob+b'\x00'*(n-len(blob)); adev.gmc.flush_hdp()
+c=am.struct_psp_gfx_cmd_resp(cmd_id=am.GFX_CMD_ID_LOAD_TA); t=c.cmd.cmd_load_ta
+t.app_phy_addr_lo,t.app_phy_addr_hi=amc&0xFFFFFFFF,amc>>32; t.app_len=len(blob)
+t.cmd_buf_phy_addr_lo,t.cmd_buf_phy_addr_hi=cmc&0xFFFFFFFF,cmc>>32; t.cmd_buf_len=WIN
+r=submit(c); sid=r.resp.session_id
+print('%s load %#x sid=%s'%(name,r.resp.status&0xFFFFFFFF,sid), flush=True)
+def inv(cid, off=None, val=0):
+ b=bytearray(WIN); struct.pack_into('<I',b,0,cid)
+ if off is not None: struct.pack_into('<I',b,off,val&0xFFFFFFFF)
+ adev.vram.view(cp,WIN)[:]=bytes(b); adev.gmc.flush_hdp()
+ c=am.struct_psp_gfx_cmd_resp(cmd_id=am.GFX_CMD_ID_INVOKE_CMD)
+ iv=c.cmd.cmd_invoke_cmd; iv.session_id,iv.ta_cmd_id=sid,cid
+ t0=time.time()
+ try: st=submit(c).resp.status&0xFFFFFFFF
+ except Exception as e:
+ try: st=int(str(e).strip().split()[-1])&0xFFFFFFFF
+ except Exception: st=-1
+ dt=time.time()-t0
+ adev.gmc.flush_hdp()
+ return st, dt, bytes(adev.vram.view(cp,0x80)[:])
+# harvest handles, then run every command once so the TA can free whatever it frees
+handles=set()
+for cid in range(0,12):
+ st,dt,out=inv(cid)
+ if dt>5: print(' stall harvesting cmd %d'%cid, flush=True); sys.exit(3)
+ for o in range(4,0x80,4):
+ v=struct.unpack_from('<I',out,o)[0]
+ if v not in (0,cid,0xFFFFFFFF): handles.add(v)
+for cid in range(0,12): inv(cid) # give the TA a chance to destroy
+print(' harvested %d handles; sweeping %d offsets x 12 cmds'%(len(handles),NOFF), flush=True)
+if not handles: print(' no handles -> test is void'); sys.exit(0)
+h=sorted(handles)[0]
+rng=random.Random(0xA5); hits=[]
+for off in range(4, 4+NOFF*4, 4):
+ for cid in (1,3,5,9):
+ sh,dth,_ = inv(cid, off, h)
+ sr,dtr,_ = inv(cid, off, rng.getrandbits(32))
+ if dth>5 or dtr>5: hits.append(('STALL',hex(off),cid)); break
+ if sh==0 and sr!=0: hits.append((hex(off),cid,'handle-accepted %#x vs random %#x'%(sh,sr)))
+ if hits and hits[-1][0]=='STALL': break
+print('%s: offsets where a harvested handle is accepted but a random value is not: %s'
+ %(name, hits[:6] if hits else 'NONE'), flush=True)