fix(libkernel): fail the signal action, mask, stack and pending calls with EFAULT on an unusable pointer #11273
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11273"
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 Gruzzberry on 2026-10-25T23:19:09Z.
What
sigaction,sigprocmask(and_sigprocmask, whichpthread_sigmaskalso reaches),sigaltstackandsigpendingread and wrote their guest pointers directly, so an unreadable or unwritable one crashed the host instead of failing. FreeBSD 11.4'ssys_sigaction,sys_sigprocmask,sys_sigaltstackandsys_sigpendingcopy the new value in first (copyin,EFAULT), then validate it (EINVALfor a bad signal number,how, or flags;ENOMEMfor a small stack), apply it, and only then copy the old value out (EFAULT, with the change already made). The calls now do the same with the newGuestCopyIn_nid_no_patch(the read counterpart ofGuestCopyOut_nid_no_patch) andGuestCopyOut_nid_no_patch. The old mask is stored before the handlers of newly unblocked pending signals run, as on FreeBSD.pthread_sigmaskreturns the error number (EFAULT) rather than -1, leaveserrnoas it was, and no longer checkshowbefore the kernel path reads the set, so a badhowwith an unreadable set givesEFAULTas insys_sigprocmask. Results and errnos for readable pointers are unchanged.sigsuspendis left alone: its null-mask throw is asserted byguest_signals.Tested
Windows 11 (10.0.26200), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
-DBUILD_TESTING=ON, on currentmain.guest_signals: newCheckSignalPointerFaultsfor an unreadable0x10action, set and stack and an unreadable or read-only old value (EFAULT), the signal number 0 andhow9 with an unreadable input (EFAULTahead ofEINVAL, pinning the order) and with a readable one (EINVAL), asigprocmaskwhose old value is unwritable still applying the block, and a null and unwritablesigpendingbuffer, andpthread_sigmaskreturning 14 for an unreadable set (also with a badhow) and for a read-only old mask but 22 for a badhowwith a readable set. Onmainthe test segfaults; with this change it passes, three runs out of three.pr_overlap_encoding,agc_host_import_cut_lifetime,agc_driver_depth_plane_partial_store).python tools/check_conventions.py --base upstream/main: passes.Overlaps
GuestCopyIn_nid_no_patchdeclaration and definition, line for line: proposed on it that it goes first and this PR rebases (the duplicate then drops out).sigaction,sigaltstackand_sigprocmaskinSignals.cpp, #10749 edits thesigactionregistration call, and #11002 editsSignals.cppandGuestSignals.cpp: proposed on each that it goes first and this PR rebases.sysctlEFAULT, mine) adds the sameGuestCopyIn_nid_no_patchlines: it was opened first, so it goes first and the duplicate drops out when this PR rebases.Checklist
main; no other open PR implements the same functionNotImplemented_nid_no_patch); no silent stubs added.mdfiles or images added to the repositoryAI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T23:20:35Z.
Review: CHANGES_REQUESTED
The new raw
sigprocmaskpath returns-1and setserrno = EFAULTfor an unreadablesetorpreviousSet.pthread_sigmask_nid_postfixforwards that result directly, but the POSIX thread API returns the error number itself (for example,EFAULT/14), not-1; FreeBSD's_pthread_sigmaskreturnserrnowhen its internal operation fails. The new tests cover onlysigprocmask_nid_postfix, so they miss this wrapper-specific behavior. Please translate the checked-copy failures to the direct error result in thepthread_sigmaskwrapper and add tests for unreadable input/output pointers there, including the wrapper's ordering whenhowis invalid. I ran exact-headgit diff --checkandtools/check_conventions.py --base upstream/main; both pass. Hosted policy checks pass, but all cross-platform relinker/sanitizer jobs are still running and full product jobs are skipped; the Windows focused tests are author-reported.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T23:27:38Z.
Review: CHANGES_REQUESTED
Re-reviewed exact head
35f349ed81852e64ee17f8068526f1bfb551f0be. The newpthread_sigmaskerror-number translation fixes the prior-1/errnoissue, but its invalid-howfast path still runs before readingset:pthread_sigmask_nid_postfix(9, unreadable, nullptr)returns 22, and the new test codifies that result. This conflicts with the PR’s stated FreeBSD ordering. In FreeBSD 11.4,__thr_sigprocmaskcopies a non-null set for everyhowexceptSIG_UNBLOCK, then calls__sys_sigprocmask; the kernelsys_sigprocmaskcopies in the set beforekern_sigprocmaskvalidateshow. Forhow == 9and an unreadable set, that path therefore returnsEFAULT(14). Please remove/defer the wrapper precheck for this case and change the regression to expect 14; keep the readable invalid-howcase expecting 22. Source: https://github.com/freebsd/freebsd-src/blob/release/11.4.0/lib/libthr/thread/thr_sig.c and https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/kern_sig.c. I ran exact-headgit diff --check upstream/main...HEADandtools/check_conventions.py --base upstream/main; both pass. Hosted policy checks pass, but the refreshed relinker/sanitizer/macOS jobs are still pending, product jobs are skipped, and the focused Windows run is author-reported rather than independently run here.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T23:41:50Z.
Review: CHANGES_REQUESTED
Re-reviewed exact head
fc123bf178c762ab7a9f467c7478b54a07a3c960. The wrapper now copiessetbefore validatinghow, and the newpthread_sigmask(9, unreadable, nullptr) == EFAULTregression addresses my prior FreeBSD-ordering finding. The remaining blocking issue is the checklist: the Overlaps section says this PR must follow #10975, #3986, #10749, #11002 and #11264, butDepends onstill saysnone. Please put the required merge-order PRs on that checklist line (or revise the overlap statement if any are no longer prerequisites). I reviewed the current diff; hosted conventions and policy checks pass, cross-platform relinker jobs are still running, product jobs are skipped, and the Windows focused tests remain author-reported rather than independently run.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T23:45:15Z.
Review: DISMISSED
Re-reviewed exact head
25d53dd03f9ddf1d6a0004202ee8d7df7f63d8c6. The newpthread_sigmaskordering and error-number behavior address my prior code findings. One blocking checklist mismatch remains: the Overlaps section says this PR must follow #10975, #3986, #10749, #11002 and #11264, but the checklist still saysDepends on: none. Please list the actual required merge-order PRs on the checklist line, or revise the overlap section if any are no longer prerequisites. Current conventions and policy checks pass; cross-platform relinker/sanitizer jobs are still running, and Linux/Windows product jobs are skipped by the workflow. The focused Windows tests are author-reported, not independently run here.