libkernel: sigaction accepts flag bits that FreeBSD 11.4 rejects with EINVAL #8409

Closed
opened 2026-10-20 12:27:52 +00:00 by xXPBSXx · 0 comments
xXPBSXx commented 2026-10-20 12:27:52 +00:00 (Migrated from github.com)
Contributor

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


Repro

sigaction(SIGUSR1 /* 30 */, &act, NULL) with act.sa_handler = a function and act.sa_flags = 0x80 (or 0x100, 0x8000, 0x40 | 0x80): returns 0 and stores the disposition.
Expected (FreeBSD 11.4 kern_sigaction, sys/kern/kern_sig.c:691-695): EINVAL when the handler is not SIG_DFL or SIG_IGN and sa_flags has a bit outside SA_ONSTACK (0x1), SA_RESTART (0x2), SA_RESETHAND (0x4), SA_NOCLDSTOP (0x8), SA_NODEFER (0x10), SA_NOCLDWAIT (0x20), SA_SIGINFO (0x40). With SIG_DFL or SIG_IGN the flags are not checked.
Actual: sigaction_nid_postfix (libkernel System/src/Signals.cpp) only checks the signal number and the SIGKILL/SIGSTOP rule.
Test: core/libs/tests/GuestSignals.cpp (new cases; guest_signals exits with 0xc0000409 before the fix).
Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/sigaction-reject-undefined-flags
AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5941617738 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8409). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T12:27:52Z. --- ### Repro `sigaction(SIGUSR1 /* 30 */, &act, NULL)` with `act.sa_handler` = a function and `act.sa_flags` = `0x80` (or `0x100`, `0x8000`, `0x40 | 0x80`): returns 0 and stores the disposition. Expected (FreeBSD 11.4 `kern_sigaction`, sys/kern/kern_sig.c:691-695): EINVAL when the handler is not SIG_DFL or SIG_IGN and `sa_flags` has a bit outside SA_ONSTACK (0x1), SA_RESTART (0x2), SA_RESETHAND (0x4), SA_NOCLDSTOP (0x8), SA_NODEFER (0x10), SA_NOCLDWAIT (0x20), SA_SIGINFO (0x40). With SIG_DFL or SIG_IGN the flags are not checked. Actual: `sigaction_nid_postfix` (libkernel `System/src/Signals.cpp`) only checks the signal number and the SIGKILL/SIGSTOP rule. Test: `core/libs/tests/GuestSignals.cpp` (new cases; `guest_signals` exits with 0xc0000409 before the fix). Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/sigaction-reject-undefined-flags AI-assisted (Claude Code).
Sign in to join this conversation.
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#8409
No description provided.