kill: allow for special rules for SIGCONT with job control
authorAlan Cox <alan@linux.intel.com>
Tue, 29 Dec 2015 22:50:47 +0000 (22:50 +0000)
committerAlan Cox <alan@linux.intel.com>
Tue, 29 Dec 2015 22:50:47 +0000 (22:50 +0000)
Kernel/include/kernel.h
Kernel/include/level2.h
Kernel/syscall_proc.c

index a31db46..d70dc4f 100644 (file)
@@ -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
 
index fdc83e5..512c78a 100644 (file)
@@ -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);
index e46220f..88c93f2 100644 (file)
@@ -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 */