fix(libkernel): return EINVAL for the semaphore arguments a PS5 rejects #11195
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11195"
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-25T21:36:22Z.
What
sceKernelCreateSemaandsceKernelSignalSemanow returnEINVALfor the arguments a retail PS5 (firmware 13.60) rejects, where they used to throw. Measured with homebrew probes from a payload process; the sources and console logs are in this gist (psema2,psema3).On the console:
sceKernelCreateSemaaccepts only attributes 0, 1, 2, 0x100, 0x101 and 0x102. Every other value tried returns0x80020016(EINVAL): 3 to 0xff, 0x103 to 0x110, 0x200, 0x201, 0x300, 0x320, 0x1000, 0x10000,0x80000000and0xffffffff.sceKernelSignalSemawith -1 or 0 returns EINVAL, and so doessceKernelPollSemawith -1 or 0.AnyPS5 threw for any attribute above 2, a negative maximum and a negative signal count, and the debt entry said they were not measured.
Bogus non-null handles (handle + 1,
0x12345) return ESRCH on the console. Here the handles are host pointers. #10558 adds a handle table for that case, so this PR does not touch it.Before and after
sceKernelCreateSemaattribute 3 to 0xff, 0x103 and above,0xffffffffEINVALEINVALEINVALEINVALsceKernelSignalSemacount -1EINVALEINVALTested
At
b7e5eb7f31: Windows 11, WinLibs GCC 15.2, full build. The four tests matchingsema|kernel_errorspass 3 times out of 3.guest_semaphorechecks EINVAL for every attribute from 3 to 0x320 except 0x100 to 0x102, and for 0x1000, 0x10000,0x80000000and0xffffffff.tools/check_conventions.pypasses. At headb7b0f58eb0(merge basemain90f918fa71),guest_semaphoreandguest_semaphore_tracepass 3 times out of 3 on Windows 11 (WinLibs GCC 15.2) and on Linux (Arch Linux on WSL2, GCC 16.2.1).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)sceKernelSignalSema) and #10789 (it edits the debt entry next to it); merge order onlyImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T21:53:35Z.
Review: APPROVED
Reviewed head
b7e5eb7f3156339366707d58295394bbe715cb9c. I independently checked the linked firmware 13.60 logs: they showEINVALfor negative/zero maximum, negative initial count, negative/zero signal and poll counts, and the tested invalid attributes; the 0x100–0x102 attributes are accepted but their behavior is deliberately left unimplemented and documented. The changed guards and regression cases match that evidence. The four Windows tests are author-reported; hosted product builds are skipped. Localgit diff --checkpasses, andcheck_conventions.pyreports no errors but does emit a non-fatal 1184-character debt-entry warning. The declared merge-order dependencies on #10558 and #9491 remain open.