fix(libkernel): refuse closing the standard descriptors with EPERM as measured on a PS5 #10136
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10136"
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 orezraey on 2026-10-23T10:35:44Z.
What
AnyPS5 does not let a title close descriptors 0 to 2 when they belong to the host process.
closereturnsEBADFandsceKernelClosereturns0x80020009. The debt entry said the console's result was unknown.I measured it on a retail PS5 (firmware 13.60) with a homebrew probe, from a payload process. The source and console logs are in this gist (
pclose,psem).close(0),close(1),close(2)on open descriptorserrno1 (EPERM); the descriptor stays open (F_GETFDstill 0)close(0)againEPERMsceKernelClose(0),(1),(2)0x80020001closeof an already closed descriptorEBADFsceKernelCloseof a closed descriptor, of -1 and of 1000000x80020009close(-1),close(100000)EBADFBoth functions now fail with
EPERM(0x80020001) on those descriptors. The debt entry records the measurement and says whether a title process can close them is unverified.Tested
Windows 11, MinGW (winlibs).
guest_host_streamnow expectsEPERMand0x80020001for open descriptors 0 to 2. It also checksEBADFand0x80020009for a closed pipe descriptor and for -1. It fails onmainand passes three runs in a row with the change.tools/check_conventions.pypasses.tools/pr_overlap.pylists PRs that touch other lines ofOpen.cpp,Stdio.cppanddocs/dev/debt/libkernel.md; none change these two checks or this debt entry.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T10:44:07Z.
Review: APPROVED
The firmware 13.60 probe in the linked gist supports the changed behavior: open descriptors 0–2 return
EPERMfromclose,0x80020001fromsceKernelClose, and remain open; a closed descriptor still yieldsEBADF/0x80020009. The implementation applies that distinction only to the host standard streams captured at library load, while the expanded test checks that they remain open and preserves closed/invalid-descriptor behavior. GCC 12.2 syntax-checked both changed implementation files andGuestHostStreams.cpplocally; the full CTest target was not runnable in this checkout. The author reports Windows focused tests passing three consecutive runs, including open, closed-pipe and invalid descriptors. Conventions, diff-check, and current-main sync pass (3 ahead/29 behind; merge clean); hosted eligibility/intake/conventions/labels pass, while product jobs are skipped by the workflow.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T11:12:12Z.
Review: APPROVED
Reviewed the exact head
5c7cdfda26ef48ea255fcdd60c33fb143845596f. The two wrappers now return EPERM for host-owned descriptors 0–2, preserving the descriptors; the regression separately checks EBADF for closed and invalid descriptors and checks both POSIX and sceKernel error mappings. The debt entry distinguishes the retail PS5 measurement from unverified title-process behavior. Hosted conventions, eligibility, intake, labels and report checks pass; all product jobs were skipped by path policy. The author reports Windows focused tests failing on main and passing three times with the change. I did not independently run the guest test. No blocking issue found.