Skip to contentSkip to conversation

signal: change sys_kill() to use SEND_SIG_NOINFO

PATCH Applied Oleg Nesterov 3 participants 7 messages Jun 26 – Jun 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 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.

Note: this also fixes the kill(-1, 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().

---
 kernel/signal.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
kernel/signal.c +1 -5
index 077effd21582..12edbf43d678 100644
@@ -3966,11 +3966,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);
 }
 
 /*
Signature · 1 line
2.52.0
#1 lore raw
Quoted 8 lines · On Fri, 26 Jun 2026 17:33:08 +0200 Oleg Nesterov <[email protected]> wrote:

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 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.

The above paragraphs contain no description of any flaw. What's wrong here?

Quoted 4 lines

Note: this also fixes the kill(-1, 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.

"also fixes". Again, what was the first fix?

Quoted 9 lines

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().

...

kernel/signal.c static void prepare_kill_siginfo(int sig, struct kernel_siginfo *info, · line 3970

Quoted 10 lines
kernel/signal.c +1 -5
@@ -3966,11 +3966,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);
 }

Thanks, I'll queue this for testing. Please send along some changelog edits sometime?

Reviewed-by
#2 lore raw
Quoted 33 lines · Andrew Morton
Quoted 8 lines · On Fri, 26 Jun 2026 17:33:08 +0200 Oleg Nesterov <[email protected]> wrote:

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 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.

The above paragraphs contain no description of any flaw. What's wrong here?

Quoted 2 lines

Note: this also fixes the kill(-1, sig) case where send_signal_locked() rewrites si_pid/si_uid in the shared siginfo, corrupting it for

subsequent

Quoted 2 lines

recipients. But for other group senders like __kill_pgrp_info() we still need the fix from Bradley Morgan [1] who found this problem.

"also fixes". Again, what was the first fix?

Quoted 2 lines

TODO: kill prepare_kill_siginfo() and change other users to use SEND_SIG_NOINFO too. This needs trivial changes in

__send_signal_locked()

kernel/signal.c static void prepare_kill_siginfo(int sig, struct

Quoted 7 lines

and TP_STORE_SIGINFO().

...

kernel/signal.c +0 -0
@@ -3966,11 +3966,7 @@ static void prepare_kill_siginfo(int sig, struct

kernel_siginfo *info,

Quoted 15 lines

kernel/signal.c static void prepare_kill_siginfo(int sig, struct kernel_siginfo *info, · line 3970

Quoted 10 lines
kernel/signal.c +1 -5
  */
 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);
 }

Thanks, I'll queue this for testing. Please send along some changelog edits sometime?

Fair enough.

If you want, please add

:)
Thanks!

#3 lore raw
In reply to Andrew Morton
Quoted 7 lines · Andrew Morton
Quoted 4 lines · On Fri, 26 Jun 2026 17:33:08 +0200 Oleg Nesterov <[email protected]> wrote:

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.

Quoted 7 lines
Quoted 4 lines

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.

The above paragraphs contain no description of any flaw. What's wrong here?

Ah, sorry. nothing wrong if we forget about the fix from Bradley, but we need this fix with or without this cleanup...

Quoted 6 lines
Quoted 4 lines

Note: this also fixes the kill(-1, 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.

"also fixes". Again, what was the first fix?

Agreed. This is confusing.

Quoted 1 line

Thanks, I'll queue this for testing.

Thanks,

Quoted 2 lines

Please send along some changelog
edits sometime?

Please see the new changelog below. Does it look more clear?

Bradley, do you agree?

Oleg.
---

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().

Reviewed-by
#4 lore raw
Quoted 14 lines · Oleg Nesterov
Quoted 2 lines · Andrew Morton

On Fri, 26 Jun 2026 17:33:08 +0200 Oleg Nesterov <[email protected]>

Quoted 10 lines · wrote:
Quoted 9 lines

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 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.

Quoted 5 lines
Quoted 2 lines

The above paragraphs contain no description of any flaw. What's wrong here?

Ah, sorry. nothing wrong if we forget about the fix from Bradley, but we need this fix with or without this cleanup...

Ack.

Quoted 11 lines
Quoted 1 line
Quoted 1 line

Note: this also fixes the kill(-1, sig) case where

send_signal_locked()

Quoted 1 line
Quoted 1 line

rewrites si_pid/si_uid in the shared siginfo, corrupting it for

subsequent

Quoted 1 line
Quoted 1 line

recipients. But for other group senders like __kill_pgrp_info() we

still

Quoted 3 lines
Quoted 1 line

need the fix from Bradley Morgan [1] who found this problem.

"also fixes". Again, what was the first fix?

Agreed. This is confusing.

Made me a bit confused! Heh.

Quoted 41 lines
Quoted 1 line

Thanks, I'll queue this for testing.

Thanks,

Quoted 2 lines

Please send along some changelog
edits sometime?

Please see the new changelog below. Does it look more clear?

Bradley, do you agree?

Oleg.
---

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.

Quoted 6 lines

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().

Code wise, please add my tag.

I would do acked by personally but no idea if that's liked over in this subsystm

Description wise, I'm sure that looks fine

Andrew, could you please take my fix?

Quoted 1 line

Thanks!

#6 lore raw
In reply to Bradley Morgan
Quoted 10 lines · On Sun, 28 Jun 2026 19:01:53 +0100 Bradley Morgan <[email protected]> wrote:
Quoted 6 lines

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().

Code wise, please add my tag.

Thanks.

I updated the changelog for this patch.

Quoted 2 lines

I would do acked by personally but no idea if that's liked over in this subsystm

Both are liked ;)

fwiw, I consider Reviewed-by to be stronger than Acked-by. I suspect the latter sometimes means "cool changelog!".

Quoted 4 lines

Description wise, I'm sure that looks fine

Andrew, could you please take my fix?

There are many fixes, so please be specific to help avoid mistakes!

I think you're referring to

	https://lore.kernel.org/all/86a8857d58d43ee26a8b365b837fd24830343494.1782159692.git.include@grrlz.net/