Repository navigation
fix(libkernel): fail the signal action, mask, stack and pending calls with EFAULT on an unusable pointer - #11273
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
The new raw sigprocmask path returns -1 and sets errno = EFAULT for an unreadable set or previousSet. pthread_sigmask_nid_postfix forwards that result directly, but the POSIX thread API returns the error number itself (for example, EFAULT/14), not -1; FreeBSD's _pthread_sigmask returns errno when its internal operation fails. The new tests cover only sigprocmask_nid_postfix, so they miss this wrapper-specific behavior. Please translate the checked-copy failures to the direct error result in the pthread_sigmask wrapper and add tests for unreadable input/output pointers there, including the wrapper's ordering when how is invalid. I ran exact-head git diff --check and tools/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.
85b78f0 to
35f349e
Compare
MarcZX10
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 35f349ed81852e64ee17f8068526f1bfb551f0be. The new pthread_sigmask error-number translation fixes the prior -1/errno issue, but its invalid-how fast path still runs before reading set: 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_sigprocmask copies a non-null set for every how except SIG_UNBLOCK, then calls __sys_sigprocmask; the kernel sys_sigprocmask copies in the set before kern_sigprocmask validates how. For how == 9 and an unreadable set, that path therefore returns EFAULT (14). Please remove/defer the wrapper precheck for this case and change the regression to expect 14; keep the readable invalid-how case 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-head git diff --check upstream/main...HEAD and tools/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.
|
One separate checklist inconsistency: the Overlaps section says this PR must follow #11264 because both branches add the identical |
35f349e to
fc123bf
Compare
MarcZX10
left a comment
There was a problem hiding this comment.
Re-reviewed exact head fc123bf178c762ab7a9f467c7478b54a07a3c960. The wrapper now copies set before validating how, and the new pthread_sigmask(9, unreadable, nullptr) == EFAULT regression 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, but Depends on still says none. 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.
fc123bf to
25d53dd
Compare
|
Fixed in 25d53dd: |
MarcZX10
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 25d53dd03f9ddf1d6a0004202ee8d7df7f63d8c6. The new pthread_sigmask ordering 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 says Depends 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.
|
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.
|
|
Checklist fixed: |
|
Windows and Linux runs of head
AI-assisted: yes (Claude Code); results above were run on this machine. |
|
@Gruzzberry heads-up: this PR and #10501 both add a trailing optional parameter to Whichever lands second keeps both parameters, e.g. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine. |
… with EFAULT on an unusable pointer FreeBSD 11.4's sys_sigaction, sys_sigprocmask and sys_sigaltstack copy their input in before validating it and copy the old value out after the change, and sys_sigpending copies out; a bad pointer gives EFAULT. The guest pointers were dereferenced directly. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
25d53dd to
1fbf3a4
Compare
Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.
|
Checked the five calls against FreeBSD 11.4 |
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, refactor(libSceLibcInternal): serve siginterrupt from libSceLibcInternal #10749 edits thesigactionregistration call, and fix(libkernel): let a guest ignore or catch SIGPIPE on Linux #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