feat(libc): implement siginterrupt through the sigaction libkernel registers #8872
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8872"
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 ycbuzi on 2026-10-21T03:54:07Z.
What
libc.prxexportssiginterrupt(TsrS8nGDQok, a libSceLibcInternal export in the public SDK's stub table) and runs FreeBSD 11.4'slib/libc/gen/siginterrupt.csequence: read the signal's disposition withsigaction, set or clear the signal's bit in_sigintrandSA_RESTARTin the flags, install the disposition again.EINVALfor a signal outside 1 to 128 comes from the firstsigaction, as there.libc cannot call libkernel (libkernel links libc), so this follows the pattern the pthread hooks already use: libc keeps a registered
sigactionand the address of the_sigintrset (RegisterSigaction_nid_no_patchinGeneral.hpp), and libkernel registers both from a static initializer inSignals.cppwhen it loads, asRegisterPthreadOnLoaddoes inThread.cpp. A call before that registration throws. The set is written outside libkernel's registration lock, as FreeBSD's libc writes it without one; the libc debt entry says so, and the libkernelsignalentry from #8866 now points here.#8866, now merged, added the
_sigintrexport tolibkerneland madesignalhonour it; this PR builds on it.Refs #8846: this PR only adds
siginterrupt. Onmain,_sigintris exported bylibkernelbut not bylibkernel_sysorlibkernel_web, which the issue also asks for, so it should stay open.Tested
Windows 11, MinGW GCC 15.2.0, Release,
BUILD_TESTING=ON, onmain05f9995704plus #8866:guest_signals, extended:siginterrupt(30, 1)sets bit 29 and clearsSA_RESTARTon the installed handler, a followingsignal(30)registers withoutSA_RESTART,siginterrupt(30, 0)clears the bit and restoresSA_RESTART; the same on signal 128 (bit 127) with the default disposition; 0, -1 and 129 fail withEINVALand leave the set alone.guest_signalspasses (1 of 1).siginterruptthrows; restored, it passes. It exits with0xc0000409andwhat(): siginterrupt: libkernel has not registered sigactionon the reverted build, and passes again on the restored one.tools/import_audit.pyon a one-line registry importingTsrS8nGDQokfromlibSceLibcInternal.prxagainst the built libraries:implemented 1, absent 0; the tool exits 1 only to note that--libshas no file namedlibSceLibcInternal.prx, whichlibc.prxserves.python tools/check_conventions.py --base origin/main --head HEADpasses.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
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T04:24:43Z.
Manual review of the overlap warning: #6565 appends a libc debt entry at the end of
debt/libc.md, where this PR also appends itssiginterruptentry; retain both entries when rebasing. TheSignals.cppoverlap with #3986 is in blocked-signal/raise logic, while this PR adds the registration hook and updatessignalfor_sigintr; #7201/#7622 touch only alarm handling. Other debt-file overlaps are unrelated entries. The code overlap is line-disjoint; the only integration change I found is keeping both appended debt entries.Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T04:30:46Z.
Thanks for the overlap check. Noted for the rebase: both libc debt entries (#6565's and the
siginterruptone here) stay, and theSignals.cpphunks (registration at the end of the file, the_sigintrline insignal) are apart from #3986's blocked-signal andraisechanges.Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-21T20:41:06Z.
Console measurement (PS5 FTP
192.168.0.144,/system/common/lib). Parsed each modulesDT_SYMTAB/DT_STRTAB` (no Ghidra)._sigintr(nQVWJEGHObc)st_infost_sizelibkernel.sprxf89a698bf7a0…STT_OBJECTSTB_GLOBALlibkernel_sys.sprx60921322b155…STT_OBJECTSTB_GLOBALlibkernel_web.sprx4ab93ee107e8…STT_OBJECTSTB_GLOBALString form in those modules is
nQVWJEGHObc#I#A. That matches a 16-bytesigset_t(fouruint32words) and the FreeBSD zero-init lead in #8846.Related
libSceLibcInternal.sprxhasnQVWJEGHObc#A#Bas an undefined import (st_size0,shndx0), not a provider.siginterrupt(TsrS8nGDQok) is aSTT_FUNCin LibcInternal (st_size128) and is absent from the three kernel modules` dynsym — consistent with putting the function in libc and the bitmap in libkernel (#8872 / #8866 split).No title run. AI-assisted parse of the pulled SPRX files.
Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-21T21:42:44Z.
Console
siginterrupt(TsrS8nGDQok) inlibSceLibcInternal.sprx, Ghidra 12.1.4 headless decompile (x86:LE:64:default:gcc), plus NID resolve:st_size128)._sigintr(nQVWJEGHObc) and callssigaddset(JUimFtKe0Kc).sigactionquery → ifflag==0clear bit in_sigintrand setSA_RESTART(|= 2), else set bit and clearSA_RESTART(&= ~2) →sigactioninstall. Stack cookie viaf7uOxY9mM1U/Ou3iL1abvng.This is static evidence from the pulled firmware module; no title run. Aligns with #8866/#8872’s FreeBSD-shaped split (bitmap in libkernel, function in libc).
Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-21T21:43:31Z.
Correction on the imported NIDs from the same Ghidra decompile (hyphens, not underscores):
UDCI-WazohQ→sigaction(already implemented)Nd-u09VFSCA→ resolve below / expectedsigdelsetJUimFtKe0Kc→sigaddset(confirmed)Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T21:52:02Z.
Checked those NIDs by hash:
Nd-u09VFSCAissigdelsetandJUimFtKe0Kcissigaddset, as you have, butUDCI-WazohQis_sigaction, notsigaction(KiJEPEWRyUY), which matches FreeBSD'ssiginterruptcalling_sigaction. #8872 calls thesigactionlibkernel registers instead of importing either, with the same steps: query, set or clear the_sigintrbit withSA_RESTARTcleared or set, install.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T00:50:26Z.
@ycbuzi on this one: #9499 registers libkernel's
sigprocmaskwith libc at the end ofSignals.cpp, where this PR registerssigaction. Both registrations stay. #9499 proposes going right after #8866 and before this PR, which would then rebase over it. If you'd rather this one went first, say so and #9499 will list it under Depends on.Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-22T01:49:39Z.
Either order works: the
sigactionregistration here and thesigprocmaskone in #9499 are separate lines at the end ofSignals.cpp, so whichever lands second rebases over the other. Going after #9499 is fine; I'll rebase this one when it lands.Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T13:25:14Z.
Review: COMMENTED
Checked against main
6cd36e6517and FreeBSD releng/11.4lib/libc/gen/siginterrupt.c:siginterrupt.c: query, set or clear the bit withSA_RESTARTcleared or set, then reinstall.EINVALcomes from the firstsigactionbefore the set is touched. The struct layout matchesGuestSigaction(32 bytes, flags at 8, mask at 12), andTsrS8nGDQokhashes fromsiginterrupt. It still merges cleanly onto main.libSceLibcInternalprx that links libkernel (core/libs/CMakeLists.txt:169) and already calls libkernel exports directly, e.g.utimes_nid_postfixinlibSceLibcInternal/FileTime.cppandfcntl/closeinDirectory.cpp. Since the console'ssiginterruptis a LibcInternal function that imports_sigaction(per the decompile above), could it live there and call_sigaction_nid_postfixand_sigintr_nid_postfixdirectly? That would dropRegisterSigaction_nid_no_patch, the static initializer at the end ofSignals.cpp(the same spot #9499 uses), the duplicatedInterruptSigaction, and the throw when a call comes before registration. I haven't checked which prx the loader resolves alibSceLibcInternalimport to, so if there's a reason it has to be libc.prx, please ignore this.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.