[MINOR] send_signal_to_group assumes PGID equals PID #30

Open
opened 2026-05-11 10:52:02 +00:00 by thabeta · 1 comment
Owner

Problem

send_signal_to_group(pid) sends to -pid, assuming the process group ID equals the PID. This is true if setpgid(0, 0) succeeded in pre_exec, but:

  1. If setpgid fails (e.g., process is already a process group leader from a parent), the signal goes to the wrong group
  2. If the process forks a child before setpgid, the child might be in the original PGID
  3. No verification that the signal actually reached the intended process group

Impact

Signals may be sent to the wrong process group, leaving child processes orphaned or killing unrelated processes.

Files

  • crates/my_init_server/src/process.rs -- send_signal_to_group
  • pre_exec closure -- setpgid call

Suggested Fix

  • Track the actual PGID (not assumed equal to PID)
  • Verify setpgid success and handle failures
  • Use cgroup-based signaling as fallback when available
## Problem `send_signal_to_group(pid)` sends to `-pid`, assuming the process group ID equals the PID. This is true if `setpgid(0, 0)` succeeded in `pre_exec`, but: 1. If `setpgid` fails (e.g., process is already a process group leader from a parent), the signal goes to the wrong group 2. If the process forks a child before `setpgid`, the child might be in the original PGID 3. No verification that the signal actually reached the intended process group ## Impact Signals may be sent to the wrong process group, leaving child processes orphaned or killing unrelated processes. ## Files - `crates/my_init_server/src/process.rs` -- `send_signal_to_group` - `pre_exec` closure -- `setpgid` call ## Suggested Fix - Track the actual PGID (not assumed equal to PID) - Verify `setpgid` success and handle failures - Use cgroup-based signaling as fallback when available
Member

Classification: valid-bug — send_signal_to_group sends to -pid assuming PGID equals PID; no verification of setpgid success, no tracking of actual PGID.

Confirmed by code inspection at process.rs:509-511. signal::kill(Pid::from_raw(-(pid as i32)), sig) assumes the process group leader PID equals the PGID.

> Classification: valid-bug — send_signal_to_group sends to -pid assuming PGID equals PID; no verification of setpgid success, no tracking of actual PGID. Confirmed by code inspection at process.rs:509-511. signal::kill(Pid::from_raw(-(pid as i32)), sig) assumes the process group leader PID equals the PGID.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
geomind_code/my_init#30
No description provided.