Proposal: a GuestPtr<T> type for guest pointer parameters, piloted on one library #19123
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Ethan-Hainline on 2026-11-12T20:19:08Z.
What
tools/guest_pointer_audit.py(from #14446) reports every export that reads or writes a guest pointer parameter withoutGuestCopyIn,GuestCopyOutor aCopyGuest*helper. Onmaine917850d23it reports 3,672 findings, of which 1,237 contain a direct dereference and 1,023 are a bare*pwith no member access, call or index. The per-function fixes keep arriving: #14445 counted 28EFAULTpull requests in two days on Oct 29–30, and the same pattern is still being opened. That issue was closed because nobody took the structural fix, not because it was rejected.This proposes the structural fix, with a small pilot instead of a flag day.
Proposal
A
GuestPtr<T>(name open) that holds a guest address and cannot be used as a hostT*:CopyIn/CopyOut(and the existingCopyGuest*helpers), which return the console error on a fault and preserveerrno;operator*, nooperator->, nodata();GuestSpan<T>later for counted arrays.An export would look like:
The existing
GuestCopyIn/GuestCopyOuthelpers stay as the implementation; the type is the compile-time gate that stops new direct accesses.Pilot
One library, chosen so the change is reviewable and does not collide with the open
EFAULTPRs.libSceVideoOutis the suggested pilot: the audit reports 25 findings there, 5 of them bare dereferences, and no open pull request changescore/libs/prx/libSceVideoOut/Export.cpp.libSceHttpis the larger alternative (38 findings, 21 bare dereferences, also no open Export.cpp PR). The pilot would:guest_pointer_audit.pyreport zero direct accesses for it;If the type is accepted, later libraries convert one at a time; the audit count becomes the burn-down metric. The largest pure-dereference buckets on this main are
libc120,libSceNpCppWebApi114 (mostly C++ member access on objects, not all guest-pointer bugs),libSceJson278,libkernel71,libSceNpCommon43,libSceNKWebKit40,libSceFont33 andlibSceIcu33.Questions
GuestPtr<T>in export signatures acceptable, or should the type be used only inside the implementation with raw pointers at the ABI boundary?libSceVideoOutthe right pilot, or should it be a smaller library (libSceZlibhas 1 finding) or a larger one?I can write the pilot once the direction is chosen. AI-assisted: yes.