Conversation
Collaborator
|
I have tested the fix using standard native tools ( 1. Process Group Signaling (
|
sc_kill mishandled the negative-pid forms. Correct them to match Linux and the qemu-aarch64 ground truth: - kill(-1, sig): broadcast to every member of the emulated fork family over the cross-process transport, excluding the caller. Per kill(2), Linux does not signal the calling process on kill(-1); the prior code did the opposite (self only, no children). Return 0 on any delivery, the first transport errno if targets existed but every send failed, else ESRCH. - kill(0, sig) and kill(-pgid, sig): deliver to every process in the target group -- children, siblings, and the parent -- not just self. Because each guest process is a separate host process, group membership is shared through a per-fork-family registry file keyed by the abstract-socket namespace id, so independent sessions stay isolated. Membership is published at fork, setpgid (self and parent-side), and setsid; publish compacts the file in place so it stays bounded by live members rather than growing per event. A process syncs its own pgid from the registry before acting on its group, so setsid's already-leader check and the kill group path observe the current group even after a parent-side setpgid(child). The registry is the single source of group membership: setpgid's group-existence check reads it directly rather than a process-table copy that could go stale after a child changes its own group. The registry and signal transport share one record reader (for_each_record) that parses newline-terminated "hostpid guestpid pgid" and "namespace tgpid signum" lines, replacing two hand-rolled chunked parsers. proc_get_namespace_targets returns (host_pid, guest_pid) pairs and, with PROC_PGID_ANY, serves both the broadcast and group paths. Recycled-pid safety: - Each transport line is tagged with the sender's namespace and the intended guest pid. A recycled host pid on an unrelated session sees a mismatched namespace; a host pid recycled onto a different guest in this same session sees a mismatched guest pid. Either mismatch drops the delivery. The drain rejects trailing garbage so a forged same-user temp-dir record cannot be accepted as a bare signal. - pgid sync matches on host pid AND guest pid so a stale record from a recycled pid cannot overwrite this process's group. - proc_send_guest_signal revalidates that the target still runs this binary before signaling. Registry lifecycle: - The namespace owner unlinks the registry only once no other live member needs it, so an owner that exits while fork children survive does not blind their group signals. - A full registry logs a warning instead of silently dropping a live member's registration. - A failed transport truncate is logged (queued signals may re-deliver) rather than ignored. Hardening: - setpgid rejects a negative group id (EINVAL) and negative pid (ESRCH), reading the args as 32-bit like sc_kill. Close #131
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.
sc_kill mishandled the negative-pid forms. Correct them to match Linux and the qemu-aarch64 ground truth:
Hardening:
Close #131
Summary by cubic
Fixes kill() negative-PID semantics to match Linux. kill(-1) now broadcasts to every member of the emulated fork family except self, and kill(0)/kill(-pgid) signal the full process group across host processes via a shared registry. Hardens signal transport to block cross-session and cross-guest PID reuse.
Bug Fixes
New Features
test-kill-broadcast,test-kill-pgroup.Written for commit 20d1be2. Summary will update on new commits.