aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/signal.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-04-03 02:24:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-04-03 02:24:32 -0400
commita816fd6b49b6b0628b968faefd49a6de4ce27066 (patch)
treeef0534be0f6ae979ea0b01b30760770bd58d9be1 /kernel/signal.c
parent4a3164e3d7be0e38a706f4345f418f2e31928332 (diff)
parent556a888a14afe27164191955618990fb3ccc9aad (diff)
Merge tag 'pidfd-fixes-v5.1-rc3' of gitolite.kernel.org:pub/scm/linux/kernel/git/brauner/linux
Pull pidfd fix from Christian Brauner: "This should be an uncontroversial fix for pidfd_send_signal() by Jann to better align it's behavior with other signal sending functions: In one of the early versions of the patchset it was suggested to not unconditionally error out when a signal with SI_USER is sent to a non-current task (cf. [1]). Instead, pidfd_send_signal() currently silently changes this to a regular kill signal. While this is technically fine, the semantics are weird since the kernel just silently converts a user's request behind their back and also no other signal sending function allows to do this. It gets more hairy when we introduce sending signals to a specific thread soon. So let's align pidfd_send_signal() with all the other signal sending functions and error out when SI_USER signals are sent to a non-current task" * tag 'pidfd-fixes-v5.1-rc3' of gitolite.kernel.org:pub/scm/linux/kernel/git/brauner/linux: signal: don't silently convert SI_USER signals to non-current pidfd
Diffstat (limited to 'kernel/signal.c')
-rw-r--r--kernel/signal.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/kernel/signal.c b/kernel/signal.c
index b7953934aa99..f98448cf2def 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -3605,16 +3605,11 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig,
3605 if (unlikely(sig != kinfo.si_signo)) 3605 if (unlikely(sig != kinfo.si_signo))
3606 goto err; 3606 goto err;
3607 3607
3608 /* Only allow sending arbitrary signals to yourself. */
3609 ret = -EPERM;
3608 if ((task_pid(current) != pid) && 3610 if ((task_pid(current) != pid) &&
3609 (kinfo.si_code >= 0 || kinfo.si_code == SI_TKILL)) { 3611 (kinfo.si_code >= 0 || kinfo.si_code == SI_TKILL))
3610 /* Only allow sending arbitrary signals to yourself. */ 3612 goto err;
3611 ret = -EPERM;
3612 if (kinfo.si_code != SI_USER)
3613 goto err;
3614
3615 /* Turn this into a regular kill signal. */
3616 prepare_kill_siginfo(sig, &kinfo);
3617 }
3618 } else { 3613 } else {
3619 prepare_kill_siginfo(sig, &kinfo); 3614 prepare_kill_siginfo(sig, &kinfo);
3620 } 3615 }