fix(libSceMoveTracker): guard guest write check with GuestArena::HostWrite #27997

Merged
NobleBrains merged 1 commit from upstream-pr/27997 into main 2026-11-29 09:38:27 +00:00
NobleBrains commented 2026-11-28 02:10:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by NobleBrains on 2026-11-28T02:10:57Z.


What

Guard guest write checks in libSceMoveTracker with GuestArena::HostWrite so invalid or unmapped guest pointers fail cleanly instead of crashing the host.

Tested

  • Linux: guest_move_tracker and guest_move_tracker_not_initialized (2/2 passed)

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream
  • Unimplemented paths throw (NotImplemented_nid_no_patch)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation of memory ranges for guest write operations. Invalid or inaccessible ranges are now rejected more consistently, while valid writable ranges continue to be accepted. This helps ensure write requests are handled according to the range’s actual accessibility and reduces the chance of incorrect validation results. Null pointers and zero-length ranges continue to receive special handling.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5535694329 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27997). Originally posted by [NobleBrains](https://github.com/NobleBrains) on 2026-11-28T02:10:57Z. --- ### What Guard guest write checks in `libSceMoveTracker` with `GuestArena::HostWrite` so invalid or unmapped guest pointers fail cleanly instead of crashing the host. ### Tested - Linux: `guest_move_tracker` and `guest_move_tracker_not_initialized` (2/2 passed) ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt and the licence notice of code adapted from upstream - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Improved validation of memory ranges for guest write operations. Invalid or inaccessible ranges are now rejected more consistently, while valid writable ranges continue to be accepted. This helps ensure write requests are handled according to the range’s actual accessibility and reduces the chance of incorrect validation results. Null pointers and zero-length ranges continue to receive special handling. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Plyxen commented 2026-11-28 05:39:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-28T05:39:01Z.

Review: APPROVED


Checked head 24b091d351. All on Windows 11 with WinLibs GCC 15.2 (Release), applied to main 4c7578e0a4 together with #27996, #27978, #27975, #27973, #27971, #27969, #27967, #27964, #27958, #27950, #27949, #27946, #27945, #27943, #27938, #27936. tools/check_conventions.py --head and tools/debt_fold.py --check passed and the full build succeeded. guest_move_tracker and guest_move_tracker_not_initialized pass. This is the platform where the change matters: on Windows GuestWritable_nid_no_patch reads the page protection, so a write-watched guest page (PAGE_READONLY) reads as unwritable unless HostWrite is open. The guard closes when IsValidGuestWrite returns, which is fine here because its only caller, sceMoveTrackerInit, writes nothing before NotImplemented. None of the existing tests puts workMemory under a write watch, so the guarded path itself is not exercised. In the full CPU suite (5,131 tests) the only failures are unrelated: windows_read_trap_unknown fails on main too (fixed in #28028), and frame_capture_minimize is a timeout under load that passes on its own.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6096089680 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27997#pullrequestreview-6096089680). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-11-28T05:39:01Z. **Review:** APPROVED --- Checked head `24b091d351`. All on Windows 11 with WinLibs GCC 15.2 (Release), applied to `main` `4c7578e0a4` together with #27996, #27978, #27975, #27973, #27971, #27969, #27967, #27964, #27958, #27950, #27949, #27946, #27945, #27943, #27938, #27936. `tools/check_conventions.py --head` and `tools/debt_fold.py --check` passed and the full build succeeded. `guest_move_tracker` and `guest_move_tracker_not_initialized` pass. This is the platform where the change matters: on Windows `GuestWritable_nid_no_patch` reads the page protection, so a write-watched guest page (`PAGE_READONLY`) reads as unwritable unless `HostWrite` is open. The guard closes when `IsValidGuestWrite` returns, which is fine here because its only caller, `sceMoveTrackerInit`, writes nothing before `NotImplemented`. None of the existing tests puts `workMemory` under a write watch, so the guarded path itself is not exercised. In the full CPU suite (5,131 tests) the only failures are unrelated: `windows_read_trap_unknown` fails on `main` too (fixed in #28028), and `frame_capture_minimize` is a timeout under load that passes on its own. AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-11-28 10:51:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T10:51:48Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation guards guest write validation with HostWrite and preserves the existing one-byte check for zero-length requests.

What I ran

Reviewed head 24b091d35104646b01611f38a6ec1981f524141e. No commands or tests were run; source was inspected through repo_read.py. No merged-preview check was performed.

Results

Check Result Note
Source review passed Changed file and guard implementation inspected
Tests not run Linux test results in the PR description were author-reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

No runtime tests were run, and behavior on Windows, macOS, or a physical console was not verified. Read: core/libs/prx/libSceMoveTracker/Export.cpp, core/libs/prx/libc/include/GuestArena.hpp, and the relevant GuestWritable_nid_no_patch implementation in core/libs/prx/libc/src/General.cpp. The prepared manifest.json shows one changed file and marks its full text included; the file was read from the pinned repository head. No files were listed as excluded in the available review bundle.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6097320624 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27997#pullrequestreview-6097320624). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-28T10:51:48Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation guards guest write validation with `HostWrite` and preserves the existing one-byte check for zero-length requests. ## What I ran Reviewed head `24b091d35104646b01611f38a6ec1981f524141e`. No commands or tests were run; source was inspected through `repo_read.py`. No merged-preview check was performed. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Changed file and guard implementation inspected | | Tests | not run | Linux test results in the PR description were author-reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No runtime tests were run, and behavior on Windows, macOS, or a physical console was not verified. Read: `core/libs/prx/libSceMoveTracker/Export.cpp`, `core/libs/prx/libc/include/GuestArena.hpp`, and the relevant `GuestWritable_nid_no_patch` implementation in `core/libs/prx/libc/src/General.cpp`. The prepared `manifest.json` shows one changed file and marks its full text included; the file was read from the pinned repository head. No files were listed as excluded in the available review bundle. ## To get this to a good state Nothing is required.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!27997
No description provided.