fix(libkernel_sys): fail fpathconf on a kqueue or shm descriptor with EOPNOTSUPP #11296

Merged
tablefrogpillow merged 4 commits from upstream-pr/11296 into main 2026-10-28 08:41:17 +00:00
tablefrogpillow commented 2026-10-26 00:47:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tablefrogpillow on 2026-10-26T00:47:57Z.


What

fpathconf on a kqueue or shm_open descriptor returned the UFS constants (_PC_LINK_MAX 32767, _PC_NAME_MAX 255, _PC_PIPE_BUF 512, …) because _fpathconf_nid_postfix only treats FIFOs and sockets as descriptors without a vnode. FreeBSD 11.4 kern_fpathconf (sys/kern/kern_descrip.c:1411-1429) answers _PC_ASYNC_IO (200112) for every descriptor and then, for a descriptor with no vnode that is not a pipe or socket, returns -1 with EOPNOTSUPP. This adds that case: a kqueue (IsKqueueDescriptor) or shared-memory (File::IsSharedMemoryDescriptor_nid_no_patch) descriptor now fails with EOPNOTSUPP for every name except _PC_ASYNC_IO.

Scope. This covers the descriptors that IsSharedMemoryDescriptor_nid_no_patch recognises: kqueue, and named shm_open objects on both Linux and Windows, plus anonymous shm_open(SHM_ANON, …) on Linux. It does not fix the Windows anonymous SHM_ANON case reported in #11291: on Windows that descriptor is not registered as shared memory, so IsSharedMemoryDescriptor_nid_no_patch returns false and fpathconf still falls through to the UFS values. That is a separate shared-descriptor-recognition gap, tracked in #11372.

Tested

Linux (Ubuntu 24.04, x86_64). ctest --test-dir build -R '^guest_kernel_sys$' passes with the change and aborts without it (guest errno 22 instead of 45). Dropping only the shared-memory half of the new branch (keeping the kqueue half) makes the named-shm_open case fail at the check, so both halves of the condition are covered. The GuestKernelSys fpathconf cases use a kqueue and a named shm_open descriptor (named recognition works on both platforms, per the Windows run reported in review). Also re-verified building and passing after a local rebase onto current main (4e43321). tools/check_conventions.py --base origin/main and tools/pr_overlap.py both clean. A Windows rerun of guest_kernel_sys would still be welcome from someone with a Windows build.

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
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none (partially addresses #11291 — kqueue and named shm_open; the Windows SHM_ANON case is tracked separately in #11372)
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5010336334 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11296). Originally posted by [tablefrogpillow](https://github.com/tablefrogpillow) on 2026-10-26T00:47:57Z. --- ### What `fpathconf` on a kqueue or `shm_open` descriptor returned the UFS constants (`_PC_LINK_MAX` 32767, `_PC_NAME_MAX` 255, `_PC_PIPE_BUF` 512, …) because `_fpathconf_nid_postfix` only treats FIFOs and sockets as descriptors without a vnode. FreeBSD 11.4 `kern_fpathconf` (sys/kern/kern_descrip.c:1411-1429) answers `_PC_ASYNC_IO` (200112) for every descriptor and then, for a descriptor with no vnode that is not a pipe or socket, returns -1 with `EOPNOTSUPP`. This adds that case: a kqueue (`IsKqueueDescriptor`) or shared-memory (`File::IsSharedMemoryDescriptor_nid_no_patch`) descriptor now fails with `EOPNOTSUPP` for every name except `_PC_ASYNC_IO`. **Scope.** This covers the descriptors that `IsSharedMemoryDescriptor_nid_no_patch` recognises: kqueue, and named `shm_open` objects on both Linux and Windows, plus anonymous `shm_open(SHM_ANON, …)` on Linux. It does **not** fix the Windows anonymous `SHM_ANON` case reported in #11291: on Windows that descriptor is not registered as shared memory, so `IsSharedMemoryDescriptor_nid_no_patch` returns false and `fpathconf` still falls through to the UFS values. That is a separate shared-descriptor-recognition gap, tracked in #11372. ### Tested Linux (Ubuntu 24.04, x86_64). `ctest --test-dir build -R '^guest_kernel_sys$'` passes with the change and aborts without it (guest errno 22 instead of 45). Dropping only the shared-memory half of the new branch (keeping the kqueue half) makes the named-`shm_open` case fail at the check, so both halves of the condition are covered. The GuestKernelSys fpathconf cases use a kqueue and a **named** `shm_open` descriptor (named recognition works on both platforms, per the Windows run reported in review). Also re-verified building and passing after a local rebase onto current `main` (`4e43321`). `tools/check_conventions.py --base origin/main` and `tools/pr_overlap.py` both clean. A Windows rerun of `guest_kernel_sys` would still be welcome from someone with a Windows build. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [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 (partially addresses #11291 — kqueue and named `shm_open`; the Windows `SHM_ANON` case is tracked separately in #11372) - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-26 00:54:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T00:54:28Z.

Review: COMMENTED


The Linux regression evidence is useful and the added branch is reached after the existing FIFO/socket handling. One validation gap remains: the reported issue includes Windows behavior, but the only focused run listed is Linux, and the hosted Windows product job is skipped for these paths. Could you run guest_kernel_sys on Windows at the exact head and record the kqueue and anonymous shared-memory cases? That would exercise the Windows GuestFstat and descriptor implementations that the Linux run does not cover. I have not independently built this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5646272471 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11296#pullrequestreview-5646272471). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T00:54:28Z. **Review:** COMMENTED --- The Linux regression evidence is useful and the added branch is reached after the existing FIFO/socket handling. One validation gap remains: the reported issue includes Windows behavior, but the only focused run listed is Linux, and the hosted Windows product job is skipped for these paths. Could you run `guest_kernel_sys` on Windows at the exact head and record the kqueue and anonymous shared-memory cases? That would exercise the Windows `GuestFstat` and descriptor implementations that the Linux run does not cover. I have not independently built this head.
MarcZX10 commented 2026-10-26 04:46:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T04:46:32Z.

Review: CHANGES_REQUESTED


The Windows follow-up exposed a failing case in the new behavior: SHM_ANON descriptors still return the UFS pathconf values, because Windows backs anonymous shared memory with a temporary file that is not present in sharedDescriptorAccess; IsSharedMemoryDescriptor_nid_no_patch therefore returns false and this new branch is skipped. That leaves the stated shared-memory behavior incomplete on Windows, and the added Windows test fails for the anonymous descriptor. Please cover the Windows anonymous shared-memory descriptor too (or narrow the claimed scope and test contract if it is intentionally unsupported), add a regression assertion, and rerun guest_kernel_sys on Windows and Linux. The existing kqueue and named-shm results do not cover this path.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5647518495 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11296#pullrequestreview-5647518495). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T04:46:32Z. **Review:** CHANGES_REQUESTED --- The Windows follow-up exposed a failing case in the new behavior: `SHM_ANON` descriptors still return the UFS pathconf values, because Windows backs anonymous shared memory with a temporary file that is not present in `sharedDescriptorAccess`; `IsSharedMemoryDescriptor_nid_no_patch` therefore returns false and this new branch is skipped. That leaves the stated shared-memory behavior incomplete on Windows, and the added Windows test fails for the anonymous descriptor. Please cover the Windows anonymous shared-memory descriptor too (or narrow the claimed scope and test contract if it is intentionally unsupported), add a regression assertion, and rerun `guest_kernel_sys` on Windows and Linux. The existing kqueue and named-shm results do not cover this path.
MarcZX10 commented 2026-10-26 07:45:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T07:45:38Z.

Review: CHANGES_REQUESTED


Thanks for changing the regression to use a named shared-memory object. That is useful cross-platform coverage for the newly added shared-descriptor check, and the prior Windows report confirms that this named object returns EOPNOTSUPP.

The issue reproduction is specifically shm_open(SHM_ANON, ...), however. Your follow-up says Windows backs that anonymous object with a temporary file that is not registered in sharedDescriptorAccess, so IsSharedMemoryDescriptor_nid_no_patch still returns false and _fpathconf_nid_postfix still falls through to the UFS constants for the reported Windows case. Please either include and test recognition of the Windows anonymous descriptor on both platforms, or narrow this PR’s stated scope to kqueue plus named shared-memory objects and leave the original SHM_ANON report explicitly unresolved (for example, with a separate issue). I am not asking anyone to close this PR.

Please also refresh onto current main (35ac3402c80b152983e8aa11196835d3a16370bf); this head is 2 commits ahead and 258 behind, and both Export.cpp and GuestKernelSys.cpp changed upstream. The merge preview is clean, but the existing Linux/Windows test reports predate the latest commit and current base. Rerun guest_kernel_sys on Linux and Windows at the rebased exact head before merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5648816408 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11296#pullrequestreview-5648816408). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T07:45:38Z. **Review:** CHANGES_REQUESTED --- Thanks for changing the regression to use a named shared-memory object. That is useful cross-platform coverage for the newly added shared-descriptor check, and the prior Windows report confirms that this named object returns `EOPNOTSUPP`. The issue reproduction is specifically `shm_open(SHM_ANON, ...)`, however. Your follow-up says Windows backs that anonymous object with a temporary file that is not registered in `sharedDescriptorAccess`, so `IsSharedMemoryDescriptor_nid_no_patch` still returns false and `_fpathconf_nid_postfix` still falls through to the UFS constants for the reported Windows case. Please either include and test recognition of the Windows anonymous descriptor on both platforms, or narrow this PR’s stated scope to kqueue plus named shared-memory objects and leave the original `SHM_ANON` report explicitly unresolved (for example, with a separate issue). I am not asking anyone to close this PR. Please also refresh onto current `main` (`35ac3402c80b152983e8aa11196835d3a16370bf`); this head is 2 commits ahead and 258 behind, and both `Export.cpp` and `GuestKernelSys.cpp` changed upstream. The merge preview is clean, but the existing Linux/Windows test reports predate the latest commit and current base. Rerun `guest_kernel_sys` on Linux and Windows at the rebased exact head before merge.
MarcZX10 commented 2026-10-26 08:11:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T08:11:00Z.

Review: CHANGES_REQUESTED


One concrete checklist mismatch remains: this PR still says Fixes #11291, but #11291 specifically reports Windows shm_open(SHM_ANON, ...), and the author confirms the current Windows code still returns the UFS values for that descriptor. Merging this checklist would auto-close an issue whose reported Windows case remains reproducible. Please either implement and test recognition of the Windows anonymous descriptor, or remove Fixes #11291 and clearly leave that case unresolved as the earlier review requested. I also refreshed sync: current upstream/main is 204c6747d0a1cbaf932def3dea0778810cc3935e; this head is 2 ahead / 261 behind. Export.cpp and GuestKernelSys.cpp changed since the base; merge preview is clean. Rebase and rerun guest_kernel_sys on Linux and Windows at the resulting exact head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5649033953 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11296#pullrequestreview-5649033953). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T08:11:00Z. **Review:** CHANGES_REQUESTED --- One concrete checklist mismatch remains: this PR still says `Fixes #11291`, but #11291 specifically reports Windows `shm_open(SHM_ANON, ...)`, and the author confirms the current Windows code still returns the UFS values for that descriptor. Merging this checklist would auto-close an issue whose reported Windows case remains reproducible. Please either implement and test recognition of the Windows anonymous descriptor, or remove `Fixes #11291` and clearly leave that case unresolved as the earlier review requested. I also refreshed sync: current `upstream/main` is `204c6747d0a1cbaf932def3dea0778810cc3935e`; this head is 2 ahead / 261 behind. `Export.cpp` and `GuestKernelSys.cpp` changed since the base; merge preview is clean. Rebase and rerun `guest_kernel_sys` on Linux and Windows at the resulting exact head.
MarcZX10 commented 2026-10-27 01:52:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T01:52:47Z.

Review: APPROVED


Re-reviewed exact head 35220d20f9a4715c0e610ce30a2676e6b2397b63 after the scope/checklist and sync follow-ups. The PR now explicitly limits itself to kqueue and the shared-memory descriptors this helper recognizes, states that Windows SHM_ANON remains unresolved in #11372, and no longer claims to close #11291. The PcAsyncIo special case remains before the new descriptor rejection; the tests cover both fpathconf aliases for a kqueue and named shared memory and check EOPNOTSUPP (errno 45). The Windows runtime report at this head passes guest_kernel_sys 3/3 with a baseline-source control; the Linux report covers the focused path and its negative control. Current-main merge preview is clean; upstream changes since the branch do not edit the modified fpathconf logic or new test block. git diff --check and conventions pass. This approval is scoped to the stated partial behavior and does not claim the Windows anonymous-shm case is fixed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5661348074 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11296#pullrequestreview-5661348074). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T01:52:47Z. **Review:** APPROVED --- Re-reviewed exact head `35220d20f9a4715c0e610ce30a2676e6b2397b63` after the scope/checklist and sync follow-ups. The PR now explicitly limits itself to kqueue and the shared-memory descriptors this helper recognizes, states that Windows `SHM_ANON` remains unresolved in #11372, and no longer claims to close #11291. The `PcAsyncIo` special case remains before the new descriptor rejection; the tests cover both `fpathconf` aliases for a kqueue and named shared memory and check `EOPNOTSUPP` (`errno 45`). The Windows runtime report at this head passes `guest_kernel_sys` 3/3 with a baseline-source control; the Linux report covers the focused path and its negative control. Current-main merge preview is clean; upstream changes since the branch do not edit the modified fpathconf logic or new test block. `git diff --check` and conventions pass. This approval is scoped to the stated partial behavior and does not claim the Windows anonymous-shm case is fixed.
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!11296
No description provided.