summaryrefslogtreecommitdiffstats
path: root/kernel/signal.c
diff options
context:
space:
mode:
authorChristian Brauner <christian@brauner.io>2019-04-17 16:50:25 -0400
committerChristian Brauner <christian@brauner.io>2019-05-07 08:31:03 -0400
commit2151ad1b067275730de1b38c7257478cae47d29e (patch)
tree45276131c61540bef60a8b9e6fde6b8b95401b54 /kernel/signal.c
parentb3e5838252665ee4cfa76b82bdf1198dca81e5be (diff)
signal: support CLONE_PIDFD with pidfd_send_signal
Let pidfd_send_signal() use pidfds retrieved via CLONE_PIDFD. With this patch pidfd_send_signal() becomes independent of procfs. This fullfils the request made when we merged the pidfd_send_signal() patchset. The pidfd_send_signal() syscall is now always available allowing for it to be used by users without procfs mounted or even users without procfs support compiled into the kernel. Signed-off-by: Christian Brauner <christian@brauner.io> Co-developed-by: Jann Horn <jannh@google.com> Signed-off-by: Jann Horn <jannh@google.com> Acked-by: Oleg Nesterov <oleg@redhat.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Kees Cook <keescook@chromium.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: David Howells <dhowells@redhat.com> Cc: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> Cc: Andy Lutomirsky <luto@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Aleksa Sarai <cyphar@cyphar.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel/signal.c')
-rw-r--r--kernel/signal.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/kernel/signal.c b/kernel/signal.c
index f98448cf2def..1581140f2d99 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -3513,7 +3513,6 @@ SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
3513 return kill_something_info(sig, &info, pid); 3513 return kill_something_info(sig, &info, pid);
3514} 3514}
3515 3515
3516#ifdef CONFIG_PROC_FS
3517/* 3516/*
3518 * Verify that the signaler and signalee either are in the same pid namespace 3517 * Verify that the signaler and signalee either are in the same pid namespace
3519 * or that the signaler's pid namespace is an ancestor of the signalee's pid 3518 * or that the signaler's pid namespace is an ancestor of the signalee's pid
@@ -3550,6 +3549,14 @@ static int copy_siginfo_from_user_any(kernel_siginfo_t *kinfo, siginfo_t *info)
3550 return copy_siginfo_from_user(kinfo, info); 3549 return copy_siginfo_from_user(kinfo, info);
3551} 3550}
3552 3551
3552static struct pid *pidfd_to_pid(const struct file *file)
3553{
3554 if (file->f_op == &pidfd_fops)
3555 return file->private_data;
3556
3557 return tgid_pidfd_to_pid(file);
3558}
3559
3553/** 3560/**
3554 * sys_pidfd_send_signal - send a signal to a process through a task file 3561 * sys_pidfd_send_signal - send a signal to a process through a task file
3555 * descriptor 3562 * descriptor
@@ -3586,7 +3593,7 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig,
3586 return -EBADF; 3593 return -EBADF;
3587 3594
3588 /* Is this a pidfd? */ 3595 /* Is this a pidfd? */
3589 pid = tgid_pidfd_to_pid(f.file); 3596 pid = pidfd_to_pid(f.file);
3590 if (IS_ERR(pid)) { 3597 if (IS_ERR(pid)) {
3591 ret = PTR_ERR(pid); 3598 ret = PTR_ERR(pid);
3592 goto err; 3599 goto err;
@@ -3620,7 +3627,6 @@ err:
3620 fdput(f); 3627 fdput(f);
3621 return ret; 3628 return ret;
3622} 3629}
3623#endif /* CONFIG_PROC_FS */
3624 3630
3625static int 3631static int
3626do_send_specific(pid_t tgid, pid_t pid, int sig, struct kernel_siginfo *info) 3632do_send_specific(pid_t tgid, pid_t pid, int sig, struct kernel_siginfo *info)