summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2026-06-26 17:33:08 +0200
committerAndrew Morton <akpm@linux-foundation.org>2026-08-03 21:10:07 -0700
commit306d71b091908bd898cbc0d7e98130354b62be2e (patch)
treec7a81c6936426f55982237d22b3ad6db4b4b3bd7 /kernel
parentd19cdc167e696714509e87d3f7ae765b6e164589 (diff)
signal: change sys_kill() to use SEND_SIG_NOINFO
prepare_kill_siginfo(PIDTYPE_TGID) fills si_code = SI_USER and sets si_pid/si_uid in the sender's namespace. Then send_signal_locked() translates si_pid/si_uid to the target's namespace. SEND_SIG_NOINFO exists precisely for the case when si_code == SI_USER and si_pid/si_uid are the sender's ids; this is exactly what sys_kill() does via prepare_kill_siginfo(PIDTYPE_TGID). Change sys_kill() to use it directly. SEND_SIG_NOINFO produces the same result: si_code = SI_USER, and __send_signal_locked() computes si_pid/si_uid directly in the target's namespace. The force computation is also the same: both check if the sender is visible in the target's pid namespace. This is just a cleanup and microoptimization (especially with [1]), this skips the has_si_pid_and_uid() block in send_signal_locked() and offloads the namespace translation logic to __send_signal_locked(SEND_SIG_NOINFO) which uses the simpler computations. NOTE: As a "side effect" this also fixes the kill(pid < 0, sig) case where send_signal_locked() rewrites si_pid/si_uid in the shared siginfo, corrupting it for subsequent recipients. But for other group senders like __kill_pgrp_info() we still need the fix from Bradley Morgan [1] who found this problem. TODO: kill prepare_kill_siginfo() and change other users to use SEND_SIG_NOINFO too. This needs trivial changes in __send_signal_locked() and TP_STORE_SIGINFO(). Link: https://lore.kernel.org/aj6btAZqYuv59a8w@redhat.com Link: https://lore.kernel.org/all/20260622164029.11474-1-include@grrlz.net/ [1] Signed-off-by: Oleg Nesterov <oleg@redhat.com> Reviewed-by: Bradley Morgan <include@grrlz.net> Cc: Eric Biederman <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/signal.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/kernel/signal.c b/kernel/signal.c
index c53f202da9da..041498ff835e 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -3962,11 +3962,7 @@ static void prepare_kill_siginfo(int sig, struct kernel_siginfo *info,
*/
SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
{
- struct kernel_siginfo info;
-
- prepare_kill_siginfo(sig, &info, PIDTYPE_TGID);
-
- return kill_something_info(sig, &info, pid);
+ return kill_something_info(sig, SEND_SIG_NOINFO, pid);
}
/*