Repository navigation
fix(libkernel): recognize Windows anonymous shared memory descriptors - #11403
oneandonlydean merged 2 commits into
Conversation
b7dc292 to
b87b825
Compare
|
Rebased onto current |
|
One test-review follow-up: |
|
Follow-up on |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
rahul05ranjan
left a comment
There was a problem hiding this comment.
Traced the Windows anonymous path end to end; the fix is consistent on every side I checked.
- Classification:
IsHostSharedMemoryDescriptoraccepts exactly<resolved temp>\AnyPS5\shm\<40 hex>.dat— no separator in the relative part, first 40 chars hex,.datsuffix (SharedMemory.cpp:110ff).CreateAnonymousFilenow names files SHA1(random || pid || serial) in hex — 40 chars plus.dat, precisely the shape the validator accepts, so the tracked descriptor and the path check agree instead of the oldanyps5-shm-...names that never validated. - The test's
reinterpret_cast<const char*>(1)is the anonymous sentinel (anonymousObject, SharedMemory.cpp:161), soshm_open(1, ReadWrite, 0600)really exercises the anonymous route. And sinceshm_open_nid_postfixrejectsO_RDONLYfor the anonymous object before calling in,TrackSharedMemoryDescriptor(..., true)'s writable flag can't be wrong here. - Hardening vs. the old code: files no longer sit in the raw
temp_directory_path()with arandom_device-seeded, counter-suffixed name; they sit underAnyPS5\shmwith an explicit private DACL (SYSTEM/administrators/owner full, no other ACEs),_O_CREAT | _O_EXCLagainst squatting, and the reparse-point check on the directories. That closes the predictable-name and inherited-ACL exposure the old placement had — with TMP redirected to a shared directory, other local accounts could previously read or pre-create the emulator's guest shared memory.
One gap worth a look: EnsurePrivateWindowsDirectory applies the private DACL only at creation and tolerates ERROR_ALREADY_EXISTS. A <temp>\AnyPS5 that already exists (older build, or anything under the same user) keeps whatever ACL it was created with — the code validates it's a directory and not a reparse point, but never its ACL. If the intent is "objects under this root are readable only by the owner", the existing-directory path would want a GetNamedSecurityInfo check or a repair step.
|
Thanks for checking the ACL behavior. I checked the existing-directory path in |
|
@MarcZX10 The Windows runtime run the hosted job skipped:
AI-assisted: yes (Claude Code) |
78c7984 to
7589525
Compare
|
@MarcZX10 four points on 7589525. I found them by reading the code; nothing was built or run. 1. 2. 3. Growing an anonymous object now writes zeros. 4. Overlap with #9019. The bot reported the test conflict, but there is more. #9019 bounds Windows anonymous writes with AI-assisted: yes (Claude Code). |
|
Windows rerun of the current head
AI-assisted: yes (Claude Code) |
7589525 to
768b29f
Compare
|
Windows run of this head ( One ordering issue: with anonymous objects now recognised as shared memory,
Each stage's build recompiled only that PR's file ( |
What
On Windows, anonymous
shm_open(SHM_ANON, ...)creates a temporary file but did not register the descriptor as shared memory.fchflagstherefore treated it like an ordinary file instead of returningEINVAL, and descriptor duplication/close tracking did not preserve its shared-memory classification.Create anonymous shared-memory files under the private Windows shared-memory root, track them as shared-memory descriptors, and add regression coverage for
fchflags, duplication, close, and descriptor reuse.Tested
x86_64-w64-mingw32-g++ -std=c++20 -D_WIN32 -D_fflush_nolock=fflush -fsyntax-only ... SharedMemory.cpp— passed.GuestNamedShmWindows.cpp— passed.git diff --check upstream/main...HEAD— passed.tools/check_conventions.py --base upstream/main --head HEAD— passed.guest_named_shm_windowswas not run locally. The automatic PR Windows product job is skipped by path policy, and the documented manual workflow dispatch requires repository admin rights; there is no hosted Windows runtime result for this head.Checklist
main; no duplicate implementation found by the open-PR overlap scan