signal: Move the computation of force into send_signal and correct it.
authorEric W. Biederman <ebiederm@xmission.com>
Thu, 16 May 2019 03:23:32 +0000 (22:23 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Wed, 29 May 2019 14:31:43 +0000 (09:31 -0500)
commit8ad23dea808042ffb8bb1b45111af6ddc1bac5d3
tree50c585c6013522be312e9d3fefa1eb4592b8b0aa
parent8917bef336f5301edd616cfa97b97d0319fd0496
signal: Move the computation of force into send_signal and correct it.

Forcing a signal or not allowing a pid namespace init to ignore
SIGKILL or SIGSTOP is more cleanly computed in send_signal.

There are two cases where we don't allow a pid namespace init
to ignore SIGKILL or SIGSTOP.  If the sending process is
from an ancestor pid namespace and as such is effectively
the god to the target process, and if the it is the kernel
that is sending the signal, not another application.

It is known that a process is from an ancestor pid namespace if
it can see it's target but it's target does not have a pid for
the sender in it's pid namespace.

It is know that a signal is sent from the kernel if si_code is set to
SI_KERNEL or info is SEND_SIG_PRIV (which ultimately generates
a signal with si_code == SI_KERNEL).

The only signals that matter are SIGKILL and SIGSTOP neither of
which can really be caught, and both of which always have a siginfo
layout that includes si_uid and si_pid.  Therefore we never need
to worry about forcing a signal when si_pid and si_uid are absent.

So handle the two special cases of info and the case when si_pid and
si_uid are present.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
kernel/signal.c