From bca4acb8ec2d9f566cf1ef1689287d8c06a8ac42 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 29 Dec 2015 22:50:47 +0000 Subject: [PATCH] kill: allow for special rules for SIGCONT with job control --- Kernel/include/kernel.h | 2 ++ Kernel/include/level2.h | 10 +++++++++- Kernel/syscall_proc.c | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Kernel/include/kernel.h b/Kernel/include/kernel.h index a31db46c..d70dc4f3 100644 --- a/Kernel/include/kernel.h +++ b/Kernel/include/kernel.h @@ -43,6 +43,8 @@ From UZI by Doug Braun and UZI280 by Stefan Nitschke. #define jobcontrol_in(x) #define jobcontrol_out(x) #define limit_exceeded(x,y) (0) +#define can_signal(p, sig) \ + (udata.u_ptab->p_uid == (p)->p_uid || super()) #endif diff --git a/Kernel/include/level2.h b/Kernel/include/level2.h index fdc83e5f..512c78ae 100644 --- a/Kernel/include/level2.h +++ b/Kernel/include/level2.h @@ -31,7 +31,15 @@ extern int tcsetpgrp(struct tty *tty, char *data); turns the whole thing into a constant 32bit comparison with a fixed or global register memory address */ #define limit_exceeded(l, v) \ - (udata.u_rlimit[(l)] < (v)) + (udata.u_rlimit[(l)] < (v)) + +/* Job control requires SIGCONT is sendable to anyone in our process group. + Untidy but we are stuck with it + + FIXME: check for any setuid funnies */ +#define can_signal(p, sig) \ + ((sig == SIGCONT && udata.u_ptab->p_session == (p)->session) \ + || udata.u_ptab->p_uid == (p)->p_uid || super()) extern arg_t _setgroups(void); extern arg_t _getgroups(void); diff --git a/Kernel/syscall_proc.c b/Kernel/syscall_proc.c index e46220f9..88c93f21 100644 --- a/Kernel/syscall_proc.c +++ b/Kernel/syscall_proc.c @@ -522,7 +522,7 @@ arg_t _kill(void) /* No overlap here */ if (-p->p_pgrp == pid || p->p_pid == pid) { f = 1; /* Found */ - if (udata.u_ptab->p_uid == p->p_uid || super()) { + if (can_signal(p, sig)) { if (sig) ssig(p, sig); s = 1; /* Signalled */ -- 2.34.1