fix(libSceNKWebKit): validate guest pointers in ParallelEnvironment exports #27936
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27936"
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 JJenkx on 2026-11-27T20:59:06Z.
What
Validate guest pointers in
WTF::ParallelEnvironmentconstructors (C1/C2) andexecuteincore/libs/prx/libSceNKWebKit/src/ParallelEnvironment.cpp:ParallelEnvironmentunderGuestArena::HostWritebefore acquiring worker pool entries or allocatingthreads.buffer, copy initialized field ranges throughGuestCopyOut_nid_no_patchwhile preserving the 4-byte padding at bytes20..23, and roll back acquired workers, refcounts, and buffer allocations if construction fails.ParallelEnvironmentand itsthreads.bufferpointer array throughGuestCopyIn_nid_no_patchinexecute, verify every non-null worker pointer uniquely matches a liveWorkerowned byThreadPool(), and callNotImplementedAt_nid_no_patchon unmapped, unreadable, unwritable, forged, or duplicate worker pointers.docs/dev/debt/changes/fix-libSceNKWebKit-parallel-environment-guest-pointers.mdand add guarded-page / read-only / split-page / invalid-worker regression coverage incore/libs/prx/libSceNKWebKit/tests/ParallelEnvironment.cpp.Tested
/mnt/sas-ssd/AnyPS5-work/agy/build-spec):TestGuestPointers()againstorigin/mainParallelEnvironment.cpp):ctest --test-dir build-spec -R '^nkwebkit_parallelenvironment$' --output-on-failure-> failed withSEGFAULT.b84b29e13e6):ctest --test-dir build-spec -R '^nkwebkit_parallelenvironment$' --output-on-failure-> 1/1 passed (0.17 sec).python3 tools/guest_pointer_audit.py libSceNKWebKit: 0 hits inParallelEnvironment.cpp.python3 tools/check_conventions.py --base origin/main: All conventions checks passed.python3 tools/pr_overlap.py --branch fix/libSceNKWebKit-parallel-environment-guest-pointers: No overlap with open pull requests.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-27T21:01:55Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
b84b29e13e:tools/check_conventions.pypassed.nkwebkit_parallelenvironment_testsbuilt cleanly.nkwebkit_parallelenvironment):core/libs/prx/libSceNKWebKit/src/ParallelEnvironment.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-27T21:06:38Z.
Review: COMMENTED
Actionable comments posted: 1
81ba5f81-03f0-4210-aa91-7fdee26c21afReviewing files that changed from the base of the PR and between
335fd4626fandb84b29e13e.core/libs/prx/libSceNKWebKit/src/ParallelEnvironment.cppcore/libs/prx/libSceNKWebKit/tests/ParallelEnvironment.cppdocs/dev/debt/changes/fix-libSceNKWebKit-parallel-environment-guest-pointers.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T21:44:22Z.
Review: DISMISSED
Reviewed — changes requested
Changes are required before merge: keep the
HostWriteguard active while copying the constructed fields to guest memory.What I ran
b84b29e13e6395c8b20eef70050f010fd444dcd9.Results
Findings
Blocking
core/libs/prx/libSceNKWebKit/src/ParallelEnvironment.cpp:78:HostWriteis destroyed whenRequireWritableGuestBytesreturns, before theGuestCopyOut_nid_no_patchcalls at lines 180 and 182. The guard therefore does not cover the writes it is meant to enable; a guest range that needsHostWritefor access can pass preflight and then fail during construction. Keep the guard alive across both copy-outs, while retaining rollback on failure.Non-blocking
None.
Not verified
core/libs/prx/libSceNKWebKit/src/ParallelEnvironment.cpp,core/libs/prx/libSceNKWebKit/tests/ParallelEnvironment.cpp,docs/dev/debt/changes/fix-libSceNKWebKit-parallel-environment-guest-pointers.md, and the prepared description, commits, manifest, and diff.To get this to a good state
Keep
HostWriteactive through the guest field copy-outs, then rerun the reported parallel-environment test and verify failure cleanup.Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-27T21:54:24Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
3cc241244c:tools/check_conventions.pypassed.nkwebkit_parallelenvironment_testsbuilt cleanly.nkwebkit_parallelenvironment):core/libs/prx/libSceNKWebKit/src/ParallelEnvironment.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-27T21:59:56Z.
Review: COMMENTED
Actionable comments posted: 1
5ed0008e-fde6-41de-9f5b-fda8f7a4de89Reviewing files that changed from the base of the PR and between
b84b29e13eand3cc241244c.core/libs/prx/libSceNKWebKit/src/ParallelEnvironment.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-28T05:39:44Z.
Review: APPROVED
Checked head
3cc241244c. All on Windows 11 with WinLibs GCC 15.2 (Release), applied tomain4c7578e0a4together with #27997, #27996, #27978, #27975, #27973, #27971, #27969, #27967, #27964, #27958, #27950, #27949, #27946, #27945, #27943, #27938.tools/check_conventions.py --headandtools/debt_fold.py --checkpassed and the full build succeeded.nkwebkit_parallelenvironmentpasses. On3cc241244ctheHostWriteguard is a local ofConstruct, so it now stays open through bothGuestCopyOut_nid_no_patchcalls, which was the blocking finding onb84b29e13e. In the full CPU suite (5,131 tests) the only failures are unrelated:windows_read_trap_unknownfails onmaintoo (fixed in #28028), andframe_capture_minimizeis a timeout under load that passes on its own.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T06:37:16Z.
Review: COMMENTED
Reviewed — comments
Nothing blocks this review; one portability point should be addressed before relying on the new regression test across supported hosts.
What I ran
Reviewed head
3cc241244c9438fbba2c4658ce81cb3a79662c4a. No commands or tests were run; the reported Linux test and other checks are author-reported only.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceNKWebKit/tests/ParallelEnvironment.cpp:306usesMAP_ANONYMOUSon every non-Windows platform. That name is not available on all supported Unix-like systems (for example, some systems exposeMAP_ANONinstead), so this test may fail to compile there. Use a platform-appropriate mapping flag or define a small compatibility alias.Not verified
No tests or prechecks were run in this review. The author reports Linux x86_64 Release test and audit results, but those were not independently verified. The prepared manifest lists three reviewed files; all three were read. No excluded changed files were listed in the manifest.
To get this to a good state
Nothing is required. Optionally make the anonymous mapping flag portable for supported non-Windows test hosts.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T08:12:57Z.
Review: COMMENTED
The parallel environment fixture passed normal worker execution and verified that malformed worker and buffer descriptions are rejected before invoking a callback.
I ran the exact fixture and changed translation unit in a focused Linux build linked against the project’s guest libraries.
AI-assisted: yes.