Harden signal safety and fix SIGSYS leak to guest#60
Merged
Conversation
0000f1a to
000044f
Compare
The supervisor's SIGSYS handler runs with SIGSYS blocked (SA_SIGINFO default). emulate_trap_rt_sigprocmask was writing the raw uc_sigmask, including that SIGSYS bit, back to the guest's old_ptr, leaking the reserved signal into the guest's visible signal state. Same leak existed in emulate_trap_rt_sigpending. This fixes both by stripping the reserved SIGSYS bit before writing to guest memory. Extract kbox_syscall_trap_sigset_strip_reserved() as the inverse of the existing kbox_syscall_trap_sigset_blocks_reserved(). Add signal safety contract documentation to procmem.c, syscall-trap.c, and seccomp-dispatch.c enumerating every signal-visible global, its protection invariant, and what breaks if multi-threaded guests are introduced. Change-Id: I67ff940a7b079990fca088ecc46a78c01162a5c1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The supervisor's SIGSYS handler runs with SIGSYS blocked (SA_SIGINFO default). emulate_trap_rt_sigprocmask was writing the raw uc_sigmask, including that SIGSYS bit, back to the guest's old_ptr, leaking the reserved signal into the guest's visible signal state. Same leak existed in emulate_trap_rt_sigpending.
This fixes both by stripping the reserved SIGSYS bit before writing to guest memory. Extract kbox_syscall_trap_sigset_strip_reserved() as the inverse of the existing kbox_syscall_trap_sigset_blocks_reserved().
Add signal safety contract documentation to procmem.c, syscall-trap.c, and seccomp-dispatch.c enumerating every signal-visible global, its protection invariant, and what breaks if multi-threaded guests are introduced.
Change-Id: I67ff940a7b079990fca088ecc46a78c01162a5c1
Summary by cubic
Fixes SIGSYS leaking into the guest and hardens signal safety across trap/dispatch. We strip SIGSYS from emulated
rt_sigprocmask/rt_sigpending, keep other signals (e.g., SIGURG) transparent, and add tests for delivery and fault recovery.Bug Fixes
rt_sigprocmask(old mask) andrt_sigpending.rt_sigprocmaskto avoid garbage bytes.rt_sigaction(SIGSEGV/SIGBUS), bump a generation counter so procmem reinstalls its fault handler; all other signals pass through (incl. SIGURG).Refactors
kbox_syscall_trap_sigset_strip_reserved()and documented signal-safety/single-thread invariants inprocmem.c,syscall-trap.c, andseccomp-dispatch.c.signal-safety-test(SIGURG passthrough, SIGSEGV guard-page recovery, SIGSYS invisibility),signal-testupdates, and procmem fault-recovery units; test runner runs the new test; exportKBOX_SYSCALL_MODEto the guest environment.Written for commit 0000091. Summary will update on new commits.