fix(libc): reject Windows guest commits over host regions #18300
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18300"
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 harry-z-kang on 2026-11-11T04:45:29Z.
What
Reject nonempty Windows guest commits that overlap host regions recorded when the arena was reserved. The bounds check alone allowed already-committed host memory to be accepted as guest memory, and native reservations reached placeholder splitting or replacement before failing.
The ownership check runs before the mapping generation changes, mapping bookkeeping, or observer callbacks. Rejected ranges leave native memory and its contents unchanged. Empty commits and commits/recommits over owned guest memory retain their existing behavior.
Related to #18252. This is complementary to #18253, which changes Windows test executable address placement; neither change depends on the other. It does not relocate a colliding host allocation or replace that PR's startup fix.
Tested
Head
a6fa09713f, based on main774111474c. Windows 1110.0.26300, Ryzen 7 9800X3D, Release,BUILD_TESTING=ON.Twelve new cases reserve host memory in a suspended child before its loader runs: reserved, committed and stack-shaped regions, with requests inside the region, crossing either boundary, or enclosing it. They check rejection, unchanged generation and observers, unchanged native mappings/protections/data, empty commits, and successful guest commits/recommits. Existing coverage includes owned memory, mapping release and mismatch handling, ordinary memory operations, fixed anonymous mappings, executable mappings, low-address allocations and crash text. Selected targets and their required libc/libkernel dependencies were rebuilt.
Negative control at main
bb520eba29: with the same regression executable and the unmodified runtime, all 12 new cases fail on each toolchain. Four cases accept committed host memory; the other eight fail after changing the mapping generation. The existingguest_memorytest passes in that control. Runtime DLLs beside the executables were explicitly synchronized with the rebuilt libraries and SHA-256 checked. Tests ran outside the restricted sandbox with fresh TEMP/TMP directories; its VirtualLock restriction and shared temporary-directory permissions otherwise obstruct the broader memory tests.Independent Windows validation of
a6fa09713fmerged onto main22cc516f87:libc.prxmade all 12 fail. Restoring the guard and refreshing the DLL brought all 12 back to passing. Test report and negative controlCompatibility run: #18253 head
977dd8053ewas temporarily applied to the pre-rebase guard commit7b5ff34724. On both compilers, rebuilt guest and host-only executables loseHIGH_ENTROPY_VAand retainDYNAMIC_BASE. Generated link commands contain--disable-high-entropy-vaexactly once for the ordinary test helper,agc_driver_frame_replay_relaunch_tests, andguest_video_out_wqhd_detection_exit_tests. The two special AGC/VideoOut executables were inspected through their generated link commands, not rebuilt or GPU-tested. The temporary changes were removed, and the guard was rebuilt and tested with main's linker settings. The final rebase preserves the guard patch unchanged.python3 tools/check_conventions.py --base origin/mainandgit diff --checkpass. No title, Linux/macOS runtime or GPU execution claim.Overlap review on 2026-11-23: manually checked all 15 branches in the current bot report against main
643d306fb0, using each branch's changes from its merge base. #1835 changes POSIX protection handling. #13589 includes a host-region lookup index with the same overlap contract used by this guard, plus separate memory helpers. #20315 adds write-watch counters and stdio build wiring. The remaining shared CMake hunks register other tests, adjust runtime staging/build wiring, or add platform tools. The guard and its twelve test registrations are separate from those changes, and no prerequisite was found.PR head
a4b0b59b40also merges cleanly onto643d306fb0. This was a source and merge review. The Windows runs above retain their recorded commit IDs.Shared-file branches manually inspected
#1835 (
c7d0a3c4c8), #7275 (4aff7f5047), #8650 (0ccd117385), #9156 (550810d74a), #9293 (b208fd6b21), #9297 (d07deaa187), #9302 (c045c1e91f), #9383 (70401ab80b), #12642 (4a30c0bf9f), #13589 (77687fbe34), #16793 (5a3664277e), #20315 (97bbe79aeb), #23786 (a2fcb097b8), #24322 (c6d13696f2), #24917 (8465e09342).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 MarcZX10 on 2026-11-12T17:28:52Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Head
a6fa09713f55096bb34a967ff92eba4ba0147020, basemain. No build and no test on this machine. I read the description, commits, manifest,files.json,diff.patchand the house-rule sections, then read the head context throughrepo_read.py(search and cat only, at the pinned head).In the Windows commit path I checked that the ownership check runs before the generation bump, the mapping commit and the observer callbacks, and that empty commits skip it (
bytes != 0).Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libc/src/GuestArena.cpp:720— The new host-region rejection throwsstd::runtime_error, while the range rejection just above it (OutsideArena,GuestArena.cpp:715) throwsstd::invalid_argument. Two kinds of rejected commit now surface as different exception types, so a caller that catches by type would treat them differently. I did not check the callers for such a catch. The test'scatch (const std::runtime_error&)depends on the current choice, so changing the type means changing the test too.Not verified
GuestArenaCommit_nid_postfix(core/libs/prx/libc/src/GuestArena.cpp:859) and the Emscripten variant (:882) have no host-region check. The description makes no Linux, macOS or WebAssembly claim, and I did not establish whether a host region can reach those paths.GuestArenaContainsandGuestArenaHostRegionOverlapsare declared incore/libs/prx/libc/include/GuestArena.hpp.GuestArenaSetAccessObserver,GuestArenaAllocate,GuestArenaRelease,GuestArenaResetandGuestArenaCommitGenerationwere not checked against the header.core/libs/CMakeLists.txt: I read the diff hunk and the surrounding block (lines 758–782 at head), not the other lines of the 1,608-line file. Thelibctarget andconfigure_windows_unwindare confirmed (core/libs/CMakeLists.txt:54and:114)._hostRegionsis filled on Windows (GuestArena.cpp:283–324) was not traced in depth.To get this to a good state
Nothing is required.
Optional:
OutsideArenafor the host-region rejection, and update the test's catch to match.guest_arena_host_commit_*CTests on the next head if the code changes.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T02:13:24Z.
Review: APPROVED
Reviewed — looks good
The reviewed change rejects nonempty guest commits overlapping recorded host regions before mapping state changes, and the inspected implementation and regression tests support the stated behavior.
What I ran
Read the prepared description, commit summary, manifest, diff, and all three changed files at head
4a08b79e0d224ae101a9ba3ca25138c5618d4bde. Usedrepo_read.pyto inspect the host-region overlap implementation and the commit call sites. No commands or tests were run in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No local build, test, or negative-control run was performed. Windows validation, compatibility checks, and convention checks are reported in the PR description and were not independently verified.
files.jsonwas not available through the reader; the manifest lists three changed files, all marked included, and each was read. No excluded-file inventory was verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-28T06:08:27Z.
Review: COMMENTED
b98f7e96-611e-45b8-9ab4-2662feb5c4b0Reviewing files that changed from the base of the PR and between
5329e1aeddand5005856944.core/libs/CMakeLists.txtcore/libs/prx/libc/src/GuestArena.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T07:00:04Z.
Review: APPROVED
Reviewed — looks good
The reviewed change rejects nonempty Windows guest commits that overlap recorded host regions before changing mapping state, and the inspected code supports merging.
What I ran
Reviewed head
5005856944e845cd649415864e17356b7d1c9953using the prepared diff and pinned readerrepo_read.py. No commands or tests were run. The PR description reports Windows test runs; these are author-supplied results.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run in this review. Author-reported Windows test results and compatibility checks were not independently verified. Read
core/libs/CMakeLists.txt,core/libs/prx/libc/src/GuestArena.cpp, andcore/libs/tests/GuestArenaHostCommitWindows.cpp; no changed files were excluded in the manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T17:28:43Z.
Review: COMMENTED
I checked
27f9d1f223with MinGW GCC 14 in syntax-only mode for bothGuestArena.cppand the new Windows fixture. Both compiled. The new ownership check precedes the trap fence, generation increment, and observer notifications. The fixture checks those effects, compares the native mappings before and after each rejected request, and then exercises ordinary guest commit and recommit. I did not run the fixture on Windows.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.