Skip to content

Commit

Permalink
signal: Pass pid type into do_send_sig_info
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ebiederm committed Jul 21, 2018
1 parent 9c2db00 commit 40b3b02
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion drivers/tty/sysrq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions fs/fcntl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion include/linux/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
10 changes: 5 additions & 5 deletions kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) \
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions mm/oom_kill.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 40b3b02

Please sign in to comment.