fix(libSceVideodec): validate output buffers before decoding and lock decoder state #27929
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27929"
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 gurtgg on 2026-11-27T20:32:34Z.
What
PictureInfowritability (GuestWritable_nid_no_patch) andinput->auDatareadability (GuestReadable_nid_no_patch, returningVideodecErrorAuPointer) insceVideodecDecodeandsceVideodecFlush(core/libs/prx/libSceVideodec/Export.cpp) before invokinglibSceVideodec2, preventing dropped frames orVideodecErrorDecodeAumisreporting.WritableRows(preservingerrno) inCopyPicturebefore writing any guest pixels so partially protected output buffers fail atomically withVideodecErrorFrameBufferPointer.Decoderinstances instd::shared_ptr<Decoder>with a per-decoderstd::mutexlocked acrosssceVideodecDecode,sceVideodecFlush,sceVideodecReset, andsceVideodecDeleteDecoder, clearingdecoder->handleunder the lock on delete to prevent use-after-free and staging-buffer races.ctrlwritability and wrapsceVideodec2CreateDecoder_nid_postfixintry/catchinsceVideodecCreateDecoderto returnVideodecErrorApiFailinstead of propagating C++ exceptions.Tested
testReadOnlyPictureInfoPreservesState(core/libs/tests/GuestVideodec.cpp): negative-control test verifying read-onlyPictureInfoinsceVideodecDecodeandsceVideodecFlushreturnsErrorArgumentPointerwithout modifyingframeBufferor losing decoded frames on retry with writablePictureInfo.testPartiallyProtectedFrameBufferUntouched(core/libs/tests/GuestVideodec.cpp): negative-control test verifying a writable luma page paired with a read-only chroma page returnsErrorFrameBufferPointerwithout mutating luma bytes.testUnreadableAuDataReturnsAuPointer(core/libs/tests/GuestVideodec.cpp): negative-control test verifying unreadable and guard-page-spanning non-nullinput->auDatareturnsErrorAuPointerinstead of0x80C10011.testReadOnlyCtrlCreateDecoder(core/libs/tests/GuestVideodec.cpp): negative-control test verifying read-onlyCtrlinsceVideodecCreateDecoderreturnsErrorArgumentPointer.testConcurrentDecodeAndDelete(core/libs/tests/GuestVideodec.cpp): concurrent stress test verifying multi-threadedsceVideodecDecode,sceVideodecFlush,sceVideodecReset, andsceVideodecDeleteDecoderexecute cleanly without races or UAF.Checklist
main; no other open PR implements the same functionstools/check_conventions.pypasses)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repositorymainand passes after fixSummary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-27T20:39:23Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
f65d238363:tools/check_conventions.pypassed.guest_videodec_testsbuilt cleanly.guest_videodec):core/libs/prx/libSceVideodec/Export.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T20:40:47Z.
Review: COMMENTED
Actionable comments posted: 1
f8720035-73b0-4798-8d59-f67d2acc623dReviewing files that changed from the base of the PR and between
fdf873a7d2andf65d238363.core/libs/prx/libSceVideodec/Export.cppcore/libs/tests/GuestVideodec.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T20:49:16Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes at
f65d238363050c28d9ceedee67dd5353cb68fef2have no verified blocking defects in the source and tests inspected.What I ran
No commands were run; this environment provides read-only review tools. I read the prepared description, commits, manifest, diff, and both changed files at the pinned head. The manifest marks both changed files as included and reviewed.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The test suite and runtime behavior were not run. The review folder lists no excluded changed files.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-27T21:09:07Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
e28812a3ee:tools/check_conventions.pypassed.guest_videodec_testsbuilt cleanly.guest_videodec):core/libs/prx/libSceVideodec/Export.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T21:19:33Z.
Review: APPROVED
Reviewed — looks good
Nothing in the inspected changes demonstrates a blocking defect; the PR description’s test claims were not run during this review.
What I ran
Reviewed head
e28812a3ee90c7cd389e794518c79171bca046dfand the prepared diff using the repository reader. No build or tests were run. No merged-preview check was run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The tests described in the PR body, runtime behavior, build compatibility, and behavior on physical console hardware were not verified. The two changed files listed as reviewed in the manifest were read:
core/libs/prx/libSceVideodec/Export.cppandcore/libs/tests/GuestVideodec.cpp. No files were excluded by the manifest;files.jsonwas not available in the review folder.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-28T05:06:00Z.
Review: APPROVED
Checked head
e28812a3ee. All on Windows 11 with WinLibs GCC 15.2 (Release), applied tomaina163d4b886together with #27930, #27926, #27925, #27924, #27923, #27922, #27901, #27828, #27771, #27755, #27748, #27682, #27765.tools/check_conventions.py --headandtools/debt_fold.py --checkpassed and the full build succeeded.guest_videodecpasses. In the full CPU suite (5,120 tests) the only failures are unrelated:windows_read_trap_unknownfails onmaintoo (fixed in #28028).frame_capture_minimize,jpeg_external_toolchainandguest_pthread_mutex_contentionare timeouts under load; they pass when run on their own.guest_audio_in_capturepasses 20/20 onmainand with #27922.One non-blocking question: the
catch (const std::exception&)aroundsceVideodec2CreateDecoder_nid_postfixalso turns aNotImplementedfrom libSceVideodec2 intoVideodecErrorApiFail. The gap is still recorded in the run report, becauseNotImplementedrecords it before it throws. But the guest then gets a definite error code for a case nobody has measured. If the catch is only there to keepdecodersconsistent, letting the exception propagate would keep that unknown visible. The swallowed exception fromsceVideodec2DeleteDecoder_nid_postfixon the cleanup path looks fine to me.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T09:18:04Z.
Review: COMMENTED
The normal Linux
guest_videodecCTest passed with the patched library and bundled decoder dependency. It covers the new output preflight, picture and frame output preservation on rejection, and the serialized decoder state cases alongside normal decode and flush.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.