fix(libkernel): reject undefined sa_flags in sigaction with EINVAL #8411

Merged
xXPBSXx merged 1 commit from upstream-pr/8411 into main 2026-10-21 18:10:36 +00:00
xXPBSXx commented 2026-10-20 12:28:03 +00:00 (Migrated from github.com)

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


What

sigaction stored any flag word. FreeBSD 11.4 kern_sigaction (sys/kern/kern_sig.c:691-695) returns EINVAL for a handler other than SIG_DFL/SIG_IGN whose sa_flags has a bit outside the seven defined ones (0x7f, sys/sys/signal.h:382-391). sigaction_nid_postfix now does the same before it touches the disposition; SIG_DFL and SIG_IGN are not checked, as in FreeBSD.
A title that passes undefined bits ran before this change; the same call fails with EINVAL on a console. This is taken from the FreeBSD source and was not measured on hardware.
Fixes #8409

Tested

Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main 56b299c3a9 + 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: flags 0x80, 0x100, 0x8000 and 0x40 | 0x80 with a handler fail with EINVAL and leave the disposition unchanged; SIG_IGN with 0x8000 still succeeds.
  • 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 (the behaviour is taken from the FreeBSD source, not measured), a title run.

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:4935711005 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8411). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T12:28:03Z. --- ### What `sigaction` stored any flag word. FreeBSD 11.4 `kern_sigaction` (sys/kern/kern_sig.c:691-695) returns `EINVAL` for a handler other than `SIG_DFL`/`SIG_IGN` whose `sa_flags` has a bit outside the seven defined ones (`0x7f`, sys/sys/signal.h:382-391). `sigaction_nid_postfix` now does the same before it touches the disposition; `SIG_DFL` and `SIG_IGN` are not checked, as in FreeBSD. A title that passes undefined bits ran before this change; the same call fails with `EINVAL` on a console. This is taken from the FreeBSD source and was not measured on hardware. Fixes #8409 ### Tested Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release, on upstream/main 56b299c3a9 + 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: flags `0x80`, `0x100`, `0x8000` and `0x40 | 0x80` with a handler fail with `EINVAL` and leave the disposition unchanged; `SIG_IGN` with `0x8000` still succeeds. - `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 (the behaviour is taken from the FreeBSD source, not measured), a title run. ### 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:40:00 +00:00 (Migrated from github.com)

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


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:6291051375 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8411#issuecomment-6291051375). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T12:40:00Z. --- <!-- 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:11:18 +00:00 (Migrated from github.com)

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


Checked against FreeBSD 11.4 kern_sigaction (kern_sig.c:691-695): same condition, SIG_DFL/SIG_IGN unchecked; the new cases fail without the change and the existing flag uses in guest_signals stay inside 0x7f; merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6323137215 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8411#issuecomment-6323137215). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-21T18:11:18Z. --- Checked against FreeBSD 11.4 kern_sigaction (kern_sig.c:691-695): same condition, SIG_DFL/SIG_IGN unchecked; the new cases fail without the change and the existing flag uses in guest_signals stay inside 0x7f; 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!8411
No description provided.