diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2018-07-21 09:17:29 -0400 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2018-07-21 13:57:41 -0400 |
commit | 9c2db007787ef1aac6728c5e03d37b0ae935d122 (patch) | |
tree | 7b05ff38eebfd71f0c0f99d6d95811964e0466a0 | |
parent | 0102498083d58d8b17759642c602b525215e1a54 (diff) |
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: "Eric W. Biederman" <ebiederm@xmission.com>
-rw-r--r-- | fs/fcntl.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/fs/fcntl.c b/fs/fcntl.c index 1523588fd759..5d596a00f40b 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -723,7 +723,7 @@ static inline int sigio_perm(struct task_struct *p, | |||
723 | 723 | ||
724 | static void send_sigio_to_task(struct task_struct *p, | 724 | static void send_sigio_to_task(struct task_struct *p, |
725 | struct fown_struct *fown, | 725 | struct fown_struct *fown, |
726 | int fd, int reason, int group) | 726 | int fd, int reason, enum pid_type type) |
727 | { | 727 | { |
728 | /* | 728 | /* |
729 | * F_SETSIG can change ->signum lockless in parallel, make | 729 | * F_SETSIG can change ->signum lockless in parallel, make |
@@ -767,11 +767,11 @@ static void send_sigio_to_task(struct task_struct *p, | |||
767 | else | 767 | else |
768 | si.si_band = mangle_poll(band_table[reason - POLL_IN]); | 768 | si.si_band = mangle_poll(band_table[reason - POLL_IN]); |
769 | si.si_fd = fd; | 769 | si.si_fd = fd; |
770 | if (!do_send_sig_info(signum, &si, p, group)) | 770 | if (!do_send_sig_info(signum, &si, p, type != PIDTYPE_PID)) |
771 | break; | 771 | break; |
772 | /* fall-through: fall back on the old plain SIGIO signal */ | 772 | /* fall-through: fall back on the old plain SIGIO signal */ |
773 | case 0: | 773 | case 0: |
774 | do_send_sig_info(SIGIO, SEND_SIG_PRIV, p, group); | 774 | do_send_sig_info(SIGIO, SEND_SIG_PRIV, p, type != PIDTYPE_PID); |
775 | } | 775 | } |
776 | } | 776 | } |
777 | 777 | ||
@@ -780,14 +780,10 @@ void send_sigio(struct fown_struct *fown, int fd, int band) | |||
780 | struct task_struct *p; | 780 | struct task_struct *p; |
781 | enum pid_type type; | 781 | enum pid_type type; |
782 | struct pid *pid; | 782 | struct pid *pid; |
783 | int group = 1; | ||
784 | 783 | ||
785 | read_lock(&fown->lock); | 784 | read_lock(&fown->lock); |
786 | 785 | ||
787 | type = fown->pid_type; | 786 | type = fown->pid_type; |
788 | if (type == PIDTYPE_PID) | ||
789 | group = 0; | ||
790 | |||
791 | pid = fown->pid; | 787 | pid = fown->pid; |
792 | if (!pid) | 788 | if (!pid) |
793 | goto out_unlock_fown; | 789 | goto out_unlock_fown; |
@@ -795,12 +791,12 @@ void send_sigio(struct fown_struct *fown, int fd, int band) | |||
795 | if (type <= PIDTYPE_TGID) { | 791 | if (type <= PIDTYPE_TGID) { |
796 | rcu_read_lock(); | 792 | rcu_read_lock(); |
797 | p = pid_task(pid, PIDTYPE_PID); | 793 | p = pid_task(pid, PIDTYPE_PID); |
798 | send_sigio_to_task(p, fown, fd, band, group); | 794 | send_sigio_to_task(p, fown, fd, band, type); |
799 | rcu_read_unlock(); | 795 | rcu_read_unlock(); |
800 | } else { | 796 | } else { |
801 | read_lock(&tasklist_lock); | 797 | read_lock(&tasklist_lock); |
802 | do_each_pid_task(pid, type, p) { | 798 | do_each_pid_task(pid, type, p) { |
803 | send_sigio_to_task(p, fown, fd, band, group); | 799 | send_sigio_to_task(p, fown, fd, band, type); |
804 | } while_each_pid_task(pid, type, p); | 800 | } while_each_pid_task(pid, type, p); |
805 | read_unlock(&tasklist_lock); | 801 | read_unlock(&tasklist_lock); |
806 | } | 802 | } |
@@ -809,10 +805,10 @@ void send_sigio(struct fown_struct *fown, int fd, int band) | |||
809 | } | 805 | } |
810 | 806 | ||
811 | static void send_sigurg_to_task(struct task_struct *p, | 807 | static void send_sigurg_to_task(struct task_struct *p, |
812 | struct fown_struct *fown, int group) | 808 | struct fown_struct *fown, enum pid_type type) |
813 | { | 809 | { |
814 | if (sigio_perm(p, fown, SIGURG)) | 810 | if (sigio_perm(p, fown, SIGURG)) |
815 | do_send_sig_info(SIGURG, SEND_SIG_PRIV, p, group); | 811 | do_send_sig_info(SIGURG, SEND_SIG_PRIV, p, type != PIDTYPE_PID); |
816 | } | 812 | } |
817 | 813 | ||
818 | int send_sigurg(struct fown_struct *fown) | 814 | int send_sigurg(struct fown_struct *fown) |
@@ -820,15 +816,11 @@ int send_sigurg(struct fown_struct *fown) | |||
820 | struct task_struct *p; | 816 | struct task_struct *p; |
821 | enum pid_type type; | 817 | enum pid_type type; |
822 | struct pid *pid; | 818 | struct pid *pid; |
823 | int group = 1; | ||
824 | int ret = 0; | 819 | int ret = 0; |
825 | 820 | ||
826 | read_lock(&fown->lock); | 821 | read_lock(&fown->lock); |
827 | 822 | ||
828 | type = fown->pid_type; | 823 | type = fown->pid_type; |
829 | if (type == PIDTYPE_PID) | ||
830 | group = 0; | ||
831 | |||
832 | pid = fown->pid; | 824 | pid = fown->pid; |
833 | if (!pid) | 825 | if (!pid) |
834 | goto out_unlock_fown; | 826 | goto out_unlock_fown; |
@@ -838,12 +830,12 @@ int send_sigurg(struct fown_struct *fown) | |||
838 | if (type <= PIDTYPE_TGID) { | 830 | if (type <= PIDTYPE_TGID) { |
839 | rcu_read_lock(); | 831 | rcu_read_lock(); |
840 | p = pid_task(pid, PIDTYPE_PID); | 832 | p = pid_task(pid, PIDTYPE_PID); |
841 | send_sigurg_to_task(p, fown, group); | 833 | send_sigurg_to_task(p, fown, type); |
842 | rcu_read_unlock(); | 834 | rcu_read_unlock(); |
843 | } else { | 835 | } else { |
844 | read_lock(&tasklist_lock); | 836 | read_lock(&tasklist_lock); |
845 | do_each_pid_task(pid, type, p) { | 837 | do_each_pid_task(pid, type, p) { |
846 | send_sigurg_to_task(p, fown, group); | 838 | send_sigurg_to_task(p, fown, type); |
847 | } while_each_pid_task(pid, type, p); | 839 | } while_each_pid_task(pid, type, p); |
848 | read_unlock(&tasklist_lock); | 840 | read_unlock(&tasklist_lock); |
849 | } | 841 | } |