You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(libc): reject Windows guest commits over host regions - #471
Source commit: 9fa33d49e40a7edc3f323a4d46d6ca07632058ef. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.
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 boykopovar#18252. This is complementary to boykopovar#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 main 774111474c. Windows 11 10.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 existing guest_memory test 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 a6fa09713f merged onto main 22cc516f87:
JJenkx ran all 12 new cases three times on Windows 11 Enterprise build 22621 with WinLibs GCC 15.2 UCRT. Every run passed without skips. Test report
Ethan-Hainline ran all 12 new cases three times on Windows 11 Pro build 26300 with WinLibs GCC 16.2.0 UCRT POSIX SEH. Every run passed without skips. Reverting only the guard and refreshing the staged libc.prx made all 12 fail. Restoring the guard and refreshing the DLL brought all 12 back to passing. Test report and negative control
Compatibility run: boykopovar#18253 head 977dd8053e was temporarily applied to the pre-rebase guard commit 7b5ff34724. On both compilers, rebuilt guest and host-only executables lose HIGH_ENTROPY_VA and retain DYNAMIC_BASE. Generated link commands contain --disable-high-entropy-va exactly once for the ordinary test helper, agc_driver_frame_replay_relaunch_tests, and guest_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/main and git diff --check pass. 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. boykopovar#1835 changes POSIX protection handling. boykopovar#13589 includes a host-region lookup index with the same overlap contract used by this guard, plus separate memory helpers. boykopovar#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 a4b0b59b40 also merges cleanly onto 643d306fb0. This was a source and merge review. The Windows runs above retain their recorded commit IDs.
No actionable comments were generated in the recent review.
Walkthrough
Changes: Host-region commit handling
Layer / File(s)
Summary
Reject commits that overlap host regions core/libs/prx/libc/src/GuestArena.cpp
GuestArenaCommit_nid_postfix now throws std::runtime_error when a non-empty commit range overlaps a host region after passing the arena containment check.
Exercise host and guest commit behavior core/libs/tests/GuestArenaHostCommitWindows.cpp, core/libs/CMakeLists.txt
The Windows tests exercise inside, prefix, suffix, and enclosing placements for reserved, committed, and stack fixtures. They check commit generation, observer callbacks, native memory metadata, initialized host data, empty commits, and guest-owned recommits. CMake registers the 12 test combinations with timeouts and the configured PATH.
Non-empty Windows guest commits that overlap host regions are now rejected before any state changes. Empty commits and guest-owned commits keep their existing behavior. I found no concrete merge-blocking risk in the change or its tests.
Security architecture risk: Minimal · up to 9fa33
Windows GuestArena now rejects nonempty commits that overlap recorded host memory before the commit can change memory or notify observers. Guest-owned commits and recommits keep their existing behavior. No introduced or worsened security risk was established.
Security review details
Security Blast Radius
observed — The production change is scoped to the Windows emulator process and to nonempty GuestArenaCommit ranges intersecting recorded host intervals. It does not add the same guard to the neighboring reset, zero-page, or shared-mapping entrypoints.
Trust Boundaries and Controls
observed — Being inside the arena's numerical bounds is no longer sufficient to reach native commit operations on Windows. The caller-supplied range must also avoid recorded host intervals before WindowsMappings can alter mappings or page protections.
Resilience and Maintainability Implications
observed — The Windows regression tests assert that overlap rejection leaves the mapping generation, observer counts, and native memory layout unchanged. Separate assertions cover zero-length commits and data preservation on guest-owned recommit.
Rollout and rollback
inferred — On the reviewed build, GuestArena itself refuses the overlapping commit even if a caller accepts the address as in bounds. There is no new operator approval or override in the change. A caller that can choose placement must use guest-owned memory rather than retry the same overlapping range. Reverting the guard restores the prior commit path without a state migration.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: dcf4d8a5-bab8-40cf-8541-df1038cea51a
Commits
Reviewing files that changed from the base of the PR and between 4131f51 and 9fa33d4.
Files selected for processing: 3
core/libs/CMakeLists.txt
core/libs/prx/libc/src/GuestArena.cpp
core/libs/tests/GuestArenaHostCommitWindows.cpp
Limit details: You’ve used all 10 included reviews currently available.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 boykopovar#18252. This is complementary to boykopovar#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: boykopovar#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. boykopovar#1835 changes POSIX protection handling. boykopovar#13589 includes a host-region lookup index with the same overlap contract used by this guard, plus separate memory helpers. boykopovar#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
boykopovar#1835 (
c7d0a3c4c8), boykopovar#7275 (4aff7f5047), boykopovar#8650 (0ccd117385), boykopovar#9156 (550810d74a), boykopovar#9293 (b208fd6b21), boykopovar#9297 (d07deaa187), boykopovar#9302 (c045c1e91f), boykopovar#9383 (70401ab80b), boykopovar#12642 (4a30c0bf9f), boykopovar#13589 (77687fbe34), boykopovar#16793 (5a3664277e), boykopovar#20315 (97bbe79aeb), boykopovar#23786 (a2fcb097b8), boykopovar#24322 (c6d13696f2), boykopovar#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