Commit 9c2db007 authored by Eric W. Biederman's avatar Eric W. Biederman

signal: Pass pid type into send_sigio_to_task & send_sigurg_to_task

This information is already present and using it directly simplifies the logic
of the code.
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parent 01024980
...@@ -723,7 +723,7 @@ static inline int sigio_perm(struct task_struct *p, ...@@ -723,7 +723,7 @@ static inline int sigio_perm(struct task_struct *p,
static void send_sigio_to_task(struct task_struct *p, static void send_sigio_to_task(struct task_struct *p,
struct fown_struct *fown, struct fown_struct *fown,
int fd, int reason, int group) int fd, int reason, enum pid_type type)
{ {
/* /*
* F_SETSIG can change ->signum lockless in parallel, make * F_SETSIG can change ->signum lockless in parallel, make
...@@ -767,11 +767,11 @@ static void send_sigio_to_task(struct task_struct *p, ...@@ -767,11 +767,11 @@ static void send_sigio_to_task(struct task_struct *p,
else else
si.si_band = mangle_poll(band_table[reason - POLL_IN]); si.si_band = mangle_poll(band_table[reason - POLL_IN]);
si.si_fd = fd; si.si_fd = fd;
if (!do_send_sig_info(signum, &si, p, group)) if (!do_send_sig_info(signum, &si, p, type != PIDTYPE_PID))
break; break;
/* fall-through: fall back on the old plain SIGIO signal */ /* fall-through: fall back on the old plain SIGIO signal */
case 0: case 0:
do_send_sig_info(SIGIO, SEND_SIG_PRIV, p, group); do_send_sig_info(SIGIO, SEND_SIG_PRIV, p, type != PIDTYPE_PID);
} }
} }
...@@ -780,14 +780,10 @@ void send_sigio(struct fown_struct *fown, int fd, int band) ...@@ -780,14 +780,10 @@ void send_sigio(struct fown_struct *fown, int fd, int band)
struct task_struct *p; struct task_struct *p;
enum pid_type type; enum pid_type type;
struct pid *pid; struct pid *pid;
int group = 1;
read_lock(&fown->lock); read_lock(&fown->lock);
type = fown->pid_type; type = fown->pid_type;
if (type == PIDTYPE_PID)
group = 0;
pid = fown->pid; pid = fown->pid;
if (!pid) if (!pid)
goto out_unlock_fown; goto out_unlock_fown;
...@@ -795,12 +791,12 @@ void send_sigio(struct fown_struct *fown, int fd, int band) ...@@ -795,12 +791,12 @@ void send_sigio(struct fown_struct *fown, int fd, int band)
if (type <= PIDTYPE_TGID) { if (type <= PIDTYPE_TGID) {
rcu_read_lock(); rcu_read_lock();
p = pid_task(pid, PIDTYPE_PID); p = pid_task(pid, PIDTYPE_PID);
send_sigio_to_task(p, fown, fd, band, group); send_sigio_to_task(p, fown, fd, band, type);
rcu_read_unlock(); rcu_read_unlock();
} else { } else {
read_lock(&tasklist_lock); read_lock(&tasklist_lock);
do_each_pid_task(pid, type, p) { do_each_pid_task(pid, type, p) {
send_sigio_to_task(p, fown, fd, band, group); send_sigio_to_task(p, fown, fd, band, type);
} while_each_pid_task(pid, type, p); } while_each_pid_task(pid, type, p);
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
} }
...@@ -809,10 +805,10 @@ void send_sigio(struct fown_struct *fown, int fd, int band) ...@@ -809,10 +805,10 @@ void send_sigio(struct fown_struct *fown, int fd, int band)
} }
static void send_sigurg_to_task(struct task_struct *p, static void send_sigurg_to_task(struct task_struct *p,
struct fown_struct *fown, int group) struct fown_struct *fown, enum pid_type type)
{ {
if (sigio_perm(p, fown, SIGURG)) if (sigio_perm(p, fown, SIGURG))
do_send_sig_info(SIGURG, SEND_SIG_PRIV, p, group); do_send_sig_info(SIGURG, SEND_SIG_PRIV, p, type != PIDTYPE_PID);
} }
int send_sigurg(struct fown_struct *fown) int send_sigurg(struct fown_struct *fown)
...@@ -820,15 +816,11 @@ int send_sigurg(struct fown_struct *fown) ...@@ -820,15 +816,11 @@ int send_sigurg(struct fown_struct *fown)
struct task_struct *p; struct task_struct *p;
enum pid_type type; enum pid_type type;
struct pid *pid; struct pid *pid;
int group = 1;
int ret = 0; int ret = 0;
read_lock(&fown->lock); read_lock(&fown->lock);
type = fown->pid_type; type = fown->pid_type;
if (type == PIDTYPE_PID)
group = 0;
pid = fown->pid; pid = fown->pid;
if (!pid) if (!pid)
goto out_unlock_fown; goto out_unlock_fown;
...@@ -838,12 +830,12 @@ int send_sigurg(struct fown_struct *fown) ...@@ -838,12 +830,12 @@ int send_sigurg(struct fown_struct *fown)
if (type <= PIDTYPE_TGID) { if (type <= PIDTYPE_TGID) {
rcu_read_lock(); rcu_read_lock();
p = pid_task(pid, PIDTYPE_PID); p = pid_task(pid, PIDTYPE_PID);
send_sigurg_to_task(p, fown, group); send_sigurg_to_task(p, fown, type);
rcu_read_unlock(); rcu_read_unlock();
} else { } else {
read_lock(&tasklist_lock); read_lock(&tasklist_lock);
do_each_pid_task(pid, type, p) { do_each_pid_task(pid, type, p) {
send_sigurg_to_task(p, fown, group); send_sigurg_to_task(p, fown, type);
} while_each_pid_task(pid, type, p); } while_each_pid_task(pid, type, p);
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment