Skip to content

feat(signal,syscall): implement SA_RESTART, sigaltstack, RT signal syscalls, and queued RT siginfo (N2.6a, #66) - #145

Merged
YUZHEthefool merged 1 commit into
mainfrom
feat/n2-6-signals-and-timers
Nov 28, 2026
Merged

YUZHEthefool merged 1 commit into
mainfrom
feat/n2-6-signals-and-timers

Conversation

@YUZHEthefool

Copy link
Copy Markdown
Member

Summary

Advances #66 (N2.6 — Signals & Timers) with N2.6a (Signals):

  • Single syscall table & ABI pinning:
    • Declared rt_sigpending(127), rt_sigtimedwait(128), rt_sigqueueinfo(129), rt_sigsuspend(130), sigaltstack(131), and rt_tgsigqueueinfo(297) in kernel/seccomp/syscall_table.rs and wired exhaustive DispatchedSyscall arms in kernel/kernel_core/syscall/mod.rs.
    • Added 24-byte #[repr(C)] StackT (stack_t) in kernel/kernel_core/syscall/abi.rs and pinned it in scripts/tools/abi_layout_oracle.py (Leg A/B/C vs native x86_64 <signal.h>).
  • Queued RT signals & siginfo_t delivery:
    • Added SigInfo (full 128-byte Linux x86_64 siginfo_t wire layout: si_signo, si_errno, si_code, si_pid, si_uid, si_value), bounded allocation-free FIFO RtSigQueue (MAX_QUEUED_RT_SIGNALS = 32 per task and per thread group, returning EAGAIN on overflow for rt_sigqueueinfo/rt_tgsigqueueinfo), and rt_sigqueueinfo/rt_tgsigqueueinfo anti-spoofing enforcement (si_code >= 0 || si_code == SI_TKILL rejected across processes with EPERM).
    • Preserved pending bit across multiple queued RT signal instances (32..=64) until drained FIFO while coalescing standard signals (1..=31).
    • Populated full siginfo_t, uc_stack, and uc_sigmask via assemble_sigframe_full on both syscall-return and IRQ-return delivery paths without disturbing SROP fixed-offset invariants.
  • Alternate signal stack (sigaltstack + SA_ONSTACK):
    • Added per-task SigAltStack (inherited on fork, disabled on clone(CLONE_VM) and execve), sys_sigaltstack (EPERM when executing on the altstack, ENOMEM when < MINSIGSTKSZ, EINVAL on unknown flags or invalid address ranges), and SigframeStack::AltStack handling in both syscall-return and IRQ-return signal delivery.
  • SA_RESTART, rt_sigpending, rt_sigsuspend, rt_sigtimedwait:
    • Implemented Linux signal(7) SA_RESTART syscall restart (rewinds RIP -= 2 and saves original syscall number in RAX inside the sigframe for restartable blocking syscalls returning EINTR; never restarts nanosleep/poll/ppoll/select/pselect6/rt_sigsuspend/rt_sigtimedwait/connect or timed futex).
    • Implemented rt_sigpending, rt_sigsuspend (reusing poll_restore_blocked so the temporary mask applies during handler delivery and rt_sigreturn restores the original mask), and rt_sigtimedwait (synchronously dequeuing pending signals even when blocked, writing 128-byte siginfo_t, honoring timeouts and EINTR).

Note: Timers & clocks (setitimer/getitimer/alarm, clock_getres, clock_nanosleep, CMOS RTC wall clock, nanosecond interpolation, POSIX timers) will follow in a separate focused N2.6b PR.

Verification

  • cargo fmt --all && make fmt-check — PASS
  • make abi-check — PASS (13 structs, 115 values, 17 tripwires, C-leg: run)
  • make lint — PASS
  • bash scripts/tools/hosted_subcrate_tests.sh — PASS (822 unit tests including 6 new N2.6a unit tests in kernel_core; kernel-core 227/227, seccomp 20/20, lsm-hook-census 5/5)
  • make clippy && make build — PASS
  • ZERO_OS_STRICT_TESTS=1 bash scripts/gates/boot/boot_check.sh — STRICT PASS (50/50)
  • ZERO_OS_STRICT_TESTS=1 SMP_CORES=4 bash scripts/gates/boot/kernel_test.sh — STRICT PASS (50/50)
  • make test-ring3-mm — PASS
  • PYTHONPATH=scripts/gates/qemu python3 -m unittest scripts/tests/qemu_run_test.py scripts/tests/qemu_trace_test.py — PASS (34/34)

Part of #66

@github-actions github-actions Bot added area: process/ABI Processes, syscalls, usercopy, signals, ELF, and Linux ABI area: security Capabilities, LSM, seccomp, audit, hardening, crypto, and livepatch area: tooling/CI Build system, scripts, hooks, automation, and repository tooling size: XL At least 1000 review lines, excluding generated/binary artifacts enhancement New feature or request labels Nov 28, 2026
@YUZHEthefool
YUZHEthefool force-pushed the feat/n2-6-signals-and-timers branch from 3d56f12 to 7644f41 Compare November 28, 2026 04:48
@YUZHEthefool
YUZHEthefool merged commit ecb5b34 into main Nov 28, 2026
29 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: process/ABI Processes, syscalls, usercopy, signals, ELF, and Linux ABI area: security Capabilities, LSM, seccomp, audit, hardening, crypto, and livepatch area: tooling/CI Build system, scripts, hooks, automation, and repository tooling enhancement New feature or request size: XL At least 1000 review lines, excluding generated/binary artifacts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant