fix(libc): refuse a macOS host write over a read-only watched page, as Windows does #28075
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28075"
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 magnub on 2026-11-28T11:38:42Z.
What
On macOS the write watch cannot see host writes, so
GuestWriteWatchBeginHostWrite_nid_postfixmarks every page of the range written as soon as a host write opens. Windows refuses the open instead when any page of the range is not writable (WindowsMappings::BeginHostWrite), and callers already treat a refused open as an unwritable destination.GuestArenaBeginHostWrite_nid_postfixnow does the same on macOS: when the write watch records a page of the range withoutPROT_WRITE, it returns false before marking anything. A host write could not land on such a page anyway, because opening it restores the recorded protection, which has no write bit.This is what broke
guest_videodec2_hevc_aliaseson macOS. The upfrontframeandoutputcheck from #21081 opens a host write over the read-only frame, and over an output that crosses into the read-only page, so pages were reported dirty although nothing was written. The code change is under__APPLE__; Linux and Windows are unchanged.Tested
Apple M1 Pro, macOS 27.0.1, x86_64 build under Rosetta 2, on main
29b14e4c5e. #17425, #11049, #26739 and #25331 were merged locally only so that main builds on macOS.guest_videodec2_hevc_aliases: fails 2/2 on main ("read-only frame dirtied watched output page"), passes 3/3 with this change.write_watch_*andguest_arena_*, before and after: the only difference is thatguest_videodec2_hevc_aliasesnow passes.guest_kernel_sysfails both before and after.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)🤖 Generated with Claude Code
https://claude.ai/code/session_012LL9hfx4BY6MbUCYMduDAQ
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T11:47:41Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the read-only protection check runs before the write watch marks any pages dirty.
What I ran
Reviewed head
54e22cc7d934e5bbc74ffee7df92ad8183ec081ffrom the prepared diff and reader-pinned source. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The author-reported macOS test results were not independently verified. No test files were changed. The review bundle’s
files.jsonwas not available, so I could not compare the read file count against itsreviewedlist.GuestArena.cppwas the only changed file listed in the manifest and was read; the remaining repository files were not read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T00:23:28Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected code supports rejecting macOS host writes that span a watched page without write permission.
What I ran
Reviewed head
93edeb564a305a6effd4244931d7f59b3a4a35cusing the prepared diff and pinned readerrepo_read.py. No tests or builds were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Tests reported in the PR description were not run independently. Only the changed
GuestArena.cppand targeted portions ofGuestWriteWatch.cppandGuestWriteWatch.hppwere read. No other changed files were listed in the manifest;files.jsonwas not available from the reader.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by NobleBrains on 2026-11-30T23:53:38Z.
Review: APPROVED
Confirmed on macOS 15.
Setup: Apple M4, macOS 15.7.9, Apple clang 17.0.0 (clang-1700.6.3.2), x86_64 Release under Rosetta,
BUILD_TESTING=ON. These are the OS and compiler generation of themacos-15runner; the description tested macOS 27.Tree:
main93d64f2d1e+ the open macOS build fixes #27201, #27739, #27843, #17425, #27827, #27767 (maindoes not build on macOS without them, see #28168) + #22091 + #28369, then #28075, #28076 and #28284 merged one after another. Each merged cleanly.guest_videodec2_hevc_aliases93edeb564aFull
ctest -j 6with all of them merged: 7038/7066 pass. Compared with the same tree before these PRs, no test fails that passed before.jsc_wtf_cpu_timeaborted once under the parallel load, then passed 5/5 on its own; it is unrelated JavaScriptCore CPU-time code.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T14:02:43Z.
Review: COMMENTED
I followed the Darwin range walk into
GuestWriteWatchProtection_nid_postfix. It advances through watched runs and unwatched gaps up to the requested end, so a range that starts writable and crosses into a watched read-only page is rejected before the write watch is opened. The Apple-specific implementation was reviewed from source because this checkout runs on Linux.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.