fix(libkernel): never block SIGKILL and SIGSTOP in sigprocmask and sigsuspend #8407

Merged
xXPBSXx merged 1 commit from upstream-pr/8407 into main 2026-10-21 18:08:52 +00:00
xXPBSXx commented 2026-10-20 12:27:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T12:27:47Z.


What

sigprocmask(SIG_BLOCK / SIG_SETMASK), pthread_sigmask (which calls it) and the mask sigsuspend installs kept SIGKILL (9) and SIGSTOP (17) in the blocked mask. FreeBSD 11.4 removes them (SIG_CANTMASK, sys/kern/kern_sig.c:1056 for SIG_BLOCK, :1067 for SIG_SETMASK; kern_sigsuspend sets its mask through kern_sigprocmask(SIG_SETMASK), :1534). The same two bits are now dropped from the word that the three paths store; SIG_UNBLOCK is unchanged.
Fixes #8405

Tested

Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main d50ec76da0 + this commit:

  • guest_signals: Exit code 0xc0000409 with System/src/Signals.cpp taken back to main (new test lines kept), passes with the change (3 of 3 runs). New cases: SIG_BLOCK and SIG_SETMASK with {SIGKILL, SIGSTOP, one other signal} read back as the other signal only (also via pthread_sigmask), and a handler run during sigsuspend sees a mask without the two bits.
  • guest_sigtimedwait, guest_itimer, guest_itimer_pending_default, guest_kill, guest_signal_sets, guest_sigaltstack, guest_getitimer pass.
  • python tools/check_conventions.py --base upstream/main: passes.
  • Not tested: Linux (not changed), a console, a title run. Overlaps #3986 (open, rewrites the same functions to a per-thread mask; its test sets bit 9 and expects it back, which FreeBSD does not allow); whichever merges second needs a small rebase.

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; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4935707907 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8407). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T12:27:47Z. --- ### What `sigprocmask(SIG_BLOCK / SIG_SETMASK)`, `pthread_sigmask` (which calls it) and the mask `sigsuspend` installs kept SIGKILL (9) and SIGSTOP (17) in the blocked mask. FreeBSD 11.4 removes them (`SIG_CANTMASK`, sys/kern/kern_sig.c:1056 for `SIG_BLOCK`, :1067 for `SIG_SETMASK`; `kern_sigsuspend` sets its mask through `kern_sigprocmask(SIG_SETMASK)`, :1534). The same two bits are now dropped from the word that the three paths store; `SIG_UNBLOCK` is unchanged. Fixes #8405 ### Tested Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main d50ec76da0 + this commit: - `guest_signals`: `Exit code 0xc0000409` with `System/src/Signals.cpp` taken back to main (new test lines kept), passes with the change (3 of 3 runs). New cases: `SIG_BLOCK` and `SIG_SETMASK` with {SIGKILL, SIGSTOP, one other signal} read back as the other signal only (also via `pthread_sigmask`), and a handler run during `sigsuspend` sees a mask without the two bits. - `guest_sigtimedwait`, `guest_itimer`, `guest_itimer_pending_default`, `guest_kill`, `guest_signal_sets`, `guest_sigaltstack`, `guest_getitimer` pass. - `python tools/check_conventions.py --base upstream/main`: passes. - Not tested: Linux (not changed), a console, a title run. Overlaps #3986 (open, rewrites the same functions to a per-thread mask; its test sets bit 9 and expects it back, which FreeBSD does not allow); whichever merges second needs a small rebase. ### Checklist - [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 - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-20 12:39:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T12:39:55Z.


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.

Pull request Shared files not compared
PR 3986 core/libs/prx/libkernel/System/src/Signals.cpp
core/libs/tests/GuestSignals.cpp
PR 6044 core/libs/tests/GuestSignals.cpp
PR 7201 core/libs/prx/libkernel/System/src/Signals.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6291049871 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8407#issuecomment-6291049871). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T12:39:55Z. --- <!-- pr-overlap --> 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. | Pull request | Shared files not compared | |---|---| | [PR 3986](https://www.github.com/boykopovar/AnyPS5/pull/3986) | `core/libs/prx/libkernel/System/src/Signals.cpp`<br>`core/libs/tests/GuestSignals.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestSignals.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel/System/src/Signals.cpp` |
adriadam10 commented 2026-10-21 18:09:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T18:09:21Z.


Checked the three paths against FreeBSD kern_sigprocmask (SIG_CANTMASK for SIG_BLOCK/SIG_SETMASK, kern_sigsuspend via SIG_SETMASK), SIG_UNBLOCK untouched, and the new guest_signals cases only pass with the mask change; merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6323098211 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8407#issuecomment-6323098211). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-21T18:09:21Z. --- Checked the three paths against FreeBSD `kern_sigprocmask` (`SIG_CANTMASK` for `SIG_BLOCK`/`SIG_SETMASK`, `kern_sigsuspend` via `SIG_SETMASK`), `SIG_UNBLOCK` untouched, and the new `guest_signals` cases only pass with the mask change; merged.
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!8407
No description provided.