fix(libSceVideoOut): copy guest pointer parameters through GuestPtr #19827
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19827"
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-14T00:48:43Z.
What
The
libSceVideoOutconversion on top of #19266.python3 tools/guest_pointer_audit.py libSceVideoOutreports 25 findings onmainand 0 here:VideoOutBufferAttribute*,VideoOutBufferAttribute2*,VideoOutBuffers*,void* const*,KernelEvent*) are copied once before use;VideoOutFlipStatus*,VideoOutVblankStatus*,VideoOutOutputStatus*,VideoOutResolutionStatus*, the label address, the event data) are built locally and copied once;optionfield;AgcDriverCheckGuestMemorycalls for those parameters are gone, so the check and the access are one operation. The display-buffer checks remain.Error behavior is preserved for nulls; an unreadable non-null pointer now takes the same path as a null one (return
VIDEO_OUT_ERROR_INVALID_ADDRESS, or throw...: VIDEO_OUT_ERROR_INVALID_ADDRESS) instead of faulting.sceVideoOutSysInitMode,sceVideoOutModeSetAny_,sceVideoOutColorSettingsSetGammaand the color-space defaults are in the throw group.This clears the audit's direct-access findings. Pointers passed into helpers are outside the audit's view and are unchanged.
Tested
Windows 11 Pro, Ryzen 5 7530U, AMD Radeon Vega 8, MinGW-w64 GCC 16.2, Release,
BUILD_TESTING=ON. Rebased ontomain9504fbb964; the head is8edaf548df(including the maintainer-added debt entry).python tools/guest_pointer_audit.py libSceVideoOut: 21 findings onmain, 0 here with the cast-aware audit.sceVideoOutSysModeIsHdr, which read the guest mode byte directly; it and thesceVideoOutSysIsModeS3d/sceVideoOutSysModeIs*queries now copy their mode fields and answer an unreadable mode with0(system-default with1), covered by the fault test. The audit is 0 under both the current matcher and the cast-plus-offset matcher proposed in #21686.ctest -R '^(guest_ptr|guest_video_out_pointer_faults|guest_video_out_resolution_status|guest_video_out_event_id|video_out_flip_(labels|controls|unopened|ps4|resolution|present|dcc))$' --output-on-failurewithANYPS5_REQUIRE_VULKAN=1: 11/11 passed on this diff before the final rebases; each rebase was clean apart fromsceVideoOutInitializeOutputOptions,sceVideoOutGetEventData,sceVideoOutColorSettingsSetGammaand the color-space defaults, where main's newer errno-preservingGuestCopyIn/GuestCopyOutis kept as-is instead of being converted toGuestPtr.guest_video_out_pointer_faultscalls the converted exports with unmapped pointers (1) and checks the return or throw: the attribute builders, option add/remove, event id/count/data,sceVideoOutSysInitMode,sceVideoOutSysModeIsHdr,sceVideoOutInitializeOutputOptions, gamma and the color-space defaults.python tools/tests/test_guest_pointer_audit.py: 21/21 passed.python tools/check_conventions.py --base main --head HEADpasses.Not tested: a Windows full-suite run and a real title; the PR jobs will run the suite.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T04:35:48Z.
Review: COMMENTED
Reviewed — comments
The guest-copy conversions are largely consistent with the stated host-safety goal, but two changed pointer paths do not yet meet that goal.
What I ran
Reviewed head
319e7bde82513b20d2a6929377c07d270db26075against the prepared diff. No commands or tests were run;repo_read.pywas used to inspect changed files and targeted repository context.Results
Findings
Blocking
None verified.
Non-blocking
InventoryExports.cpp:21formsmode + 0x20before validating/copying the pointer. For a non-null but invalid address near the top of the address space, this pointer arithmetic can overflow beforeGuestBytes::CopyIncan safely reject the address. Consider validating the base range or using an overflow-safe address calculation before adding the offset.Output.cpp:169-396hassceVideoOutModeSetAny_write the size first, then fill the remaining range in separate 256-byte guest copies. If a later chunk is unreadable, the function returns by throwing after partially modifying guest memory; this does not match the description’s claim that output parameters are built locally and copied once. Consider validating/writing the complete output through one guest-copy operation, or documenting and testing the partial-write behavior.Not verified
No test/build commands were run. The Windows full suite and real-title behavior were not verified. The author-reported test results in
description.mdwere not independently run. All seven changed files listed inmanifest.jsonwere read; none were excluded by the manifest.To get this to a good state
Nothing is required. Optional: make the mode offset calculation overflow-safe and clarify or make atomic the variable-length mode output copy.