signal: Pass pid type into do_send_sig_info
authorEric W. Biederman <ebiederm@xmission.com>
Sat, 21 Jul 2018 15:45:15 +0000 (10:45 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Sat, 21 Jul 2018 17:57:35 +0000 (12:57 -0500)
This passes the information we already have at the call sight into
do_send_sig_info.  Ultimately allowing for better handling of signals
sent to a group of processes during fork.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
drivers/tty/sysrq.c
fs/fcntl.c
include/linux/signal.h
kernel/signal.c
mm/oom_kill.c

index 6364890575ec03a54b70e24bdb3dce37285a938c..06ed20dd01ba6f9cc443c690f04c131f09790cba 100644 (file)
@@ -348,7 +348,7 @@ static void send_sig_all(int sig)
                if (is_global_init(p))
                        continue;
 
-               do_send_sig_info(sig, SEND_SIG_FORCED, p, true);
+               do_send_sig_info(sig, SEND_SIG_FORCED, p, PIDTYPE_MAX);
        }
        read_unlock(&tasklist_lock);
 }
index 5d596a00f40b0fb6e790a2045adb98b56a56ed26..a04accf6847f301b06dad01d278f2bf2d528c1d8 100644 (file)
@@ -767,11 +767,11 @@ static void send_sigio_to_task(struct task_struct *p,
                        else
                                si.si_band = mangle_poll(band_table[reason - POLL_IN]);
                        si.si_fd    = fd;
-                       if (!do_send_sig_info(signum, &si, p, type != PIDTYPE_PID))
+                       if (!do_send_sig_info(signum, &si, p, type))
                                break;
                /* fall-through: fall back on the old plain SIGIO signal */
                case 0:
-                       do_send_sig_info(SIGIO, SEND_SIG_PRIV, p, type != PIDTYPE_PID);
+                       do_send_sig_info(SIGIO, SEND_SIG_PRIV, p, type);
        }
 }
 
@@ -808,7 +808,7 @@ static void send_sigurg_to_task(struct task_struct *p,
                                struct fown_struct *fown, enum pid_type type)
 {
        if (sigio_perm(p, fown, SIGURG))
-               do_send_sig_info(SIGURG, SEND_SIG_PRIV, p, type != PIDTYPE_PID);
+               do_send_sig_info(SIGURG, SEND_SIG_PRIV, p, type);
 }
 
 int send_sigurg(struct fown_struct *fown)
index d8f2bf3d41e6a22a876c263042f5d4e42a6dd29f..fe125b0335f7dba28ac0344b6527d86505da605e 100644 (file)
@@ -258,7 +258,7 @@ enum pid_type;
 
 extern int next_signal(struct sigpending *pending, sigset_t *mask);
 extern int do_send_sig_info(int sig, struct siginfo *info,
-                               struct task_struct *p, bool group);
+                               struct task_struct *p, enum pid_type type);
 extern int group_send_sig_info(int sig, struct siginfo *info,
                               struct task_struct *p, enum pid_type type);
 extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
index c7527338fe9d2bdc215c1f272ae59b809174ac5e..2c09e6143dd8b729579660fac782f7a0b11cfce4 100644 (file)
@@ -1161,13 +1161,13 @@ specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
 }
 
 int do_send_sig_info(int sig, struct siginfo *info, struct task_struct *p,
-                       bool group)
+                       enum pid_type type)
 {
        unsigned long flags;
        int ret = -ESRCH;
 
        if (lock_task_sighand(p, &flags)) {
-               ret = send_signal(sig, info, p, group);
+               ret = send_signal(sig, info, p, type != PIDTYPE_PID);
                unlock_task_sighand(p, &flags);
        }
 
@@ -1284,7 +1284,7 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p,
        rcu_read_unlock();
 
        if (!ret && sig)
-               ret = do_send_sig_info(sig, info, p, true);
+               ret = do_send_sig_info(sig, info, p, type);
 
        return ret;
 }
@@ -1448,7 +1448,7 @@ int send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
        if (!valid_signal(sig))
                return -EINVAL;
 
-       return do_send_sig_info(sig, info, p, false);
+       return do_send_sig_info(sig, info, p, PIDTYPE_PID);
 }
 
 #define __si_special(priv) \
@@ -3199,7 +3199,7 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
                 * probe.  No signal is actually delivered.
                 */
                if (!error && sig) {
-                       error = do_send_sig_info(sig, info, p, false);
+                       error = do_send_sig_info(sig, info, p, PIDTYPE_PID);
                        /*
                         * If lock_task_sighand() failed we pretend the task
                         * dies after receiving the signal. The window is tiny,
index 84081e77bc51cec7a9089937429046b7107aa027..2cc9b238368f2576b48a3e36441a817661a19f0e 100644 (file)
@@ -920,7 +920,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message)
         * in order to prevent the OOM victim from depleting the memory
         * reserves from the user space under its control.
         */
-       do_send_sig_info(SIGKILL, SEND_SIG_FORCED, victim, true);
+       do_send_sig_info(SIGKILL, SEND_SIG_FORCED, victim, PIDTYPE_TGID);
        mark_oom_victim(victim);
        pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n",
                task_pid_nr(victim), victim->comm, K(victim->mm->total_vm),
@@ -958,7 +958,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message)
                 */
                if (unlikely(p->flags & PF_KTHREAD))
                        continue;
-               do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true);
+               do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, PIDTYPE_TGID);
        }
        rcu_read_unlock();