Skip to content

Commit

Permalink
signals: zap_pid_ns_process() should use force_sig()
Browse files Browse the repository at this point in the history
send_signal() assumes that signals with SEND_SIG_PRIV are generated from
within the same namespace.  So any nested container-init processes become
immune to the SIGKILL generated by kill_proc_info() in
zap_pid_ns_processes().

Use force_sig() in zap_pid_ns_processes() instead - force_sig() clears the
SIGNAL_UNKILLABLE flag ensuring the signal is processed by
container-inits.

Signed-off-by: Sukadev Bhattiprolu <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Roland McGrath <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Daniel Lezcano <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Sukadev Bhattiprolu authored and torvalds committed Apr 3, 2009
1 parent 921cf9f commit e4da026
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion kernel/pid_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
{
int nr;
int rc;
struct task_struct *task;

/*
* The last thread in the cgroup-init thread group is terminating.
Expand All @@ -169,7 +170,19 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
read_lock(&tasklist_lock);
nr = next_pidmap(pid_ns, 1);
while (nr > 0) {
kill_proc_info(SIGKILL, SEND_SIG_PRIV, nr);
rcu_read_lock();

/*
* Use force_sig() since it clears SIGNAL_UNKILLABLE ensuring
* any nested-container's init processes don't ignore the
* signal
*/
task = pid_task(find_vpid(nr), PIDTYPE_PID);
if (task)
force_sig(SIGKILL, task);

rcu_read_unlock();

nr = next_pidmap(pid_ns, nr);
}
read_unlock(&tasklist_lock);
Expand Down

0 comments on commit e4da026

Please sign in to comment.