diff options
-rw-r--r-- | fs/exec.c | 4 | ||||
-rw-r--r-- | fs/proc/base.c | 2 | ||||
-rw-r--r-- | include/linux/sched.h | 6 | ||||
-rw-r--r-- | kernel/posix-cpu-timers.c | 12 | ||||
-rw-r--r-- | kernel/posix-timers.c | 4 | ||||
-rw-r--r-- | kernel/ptrace.c | 2 | ||||
-rw-r--r-- | kernel/signal.c | 2 | ||||
-rw-r--r-- | mm/oom_kill.c | 2 |
8 files changed, 20 insertions, 14 deletions
@@ -841,8 +841,8 @@ static int de_thread(struct task_struct *tsk) | |||
841 | */ | 841 | */ |
842 | tsk->start_time = leader->start_time; | 842 | tsk->start_time = leader->start_time; |
843 | 843 | ||
844 | BUG_ON(leader->tgid != tsk->tgid); | 844 | BUG_ON(!same_thread_group(leader, tsk)); |
845 | BUG_ON(tsk->pid == tsk->tgid); | 845 | BUG_ON(has_group_leader_pid(tsk)); |
846 | /* | 846 | /* |
847 | * An exec() starts a new thread group with the | 847 | * An exec() starts a new thread group with the |
848 | * TGID of the previous thread group. Rehash the | 848 | * TGID of the previous thread group. Rehash the |
diff --git a/fs/proc/base.c b/fs/proc/base.c index db7636041c10..991482811f1e 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -2553,7 +2553,7 @@ static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry | |||
2553 | rcu_read_unlock(); | 2553 | rcu_read_unlock(); |
2554 | if (!task) | 2554 | if (!task) |
2555 | goto out; | 2555 | goto out; |
2556 | if (leader->tgid != task->tgid) | 2556 | if (!same_thread_group(leader, task)) |
2557 | goto out_drop_task; | 2557 | goto out_drop_task; |
2558 | 2558 | ||
2559 | result = proc_task_instantiate(dir, dentry, task, NULL); | 2559 | result = proc_task_instantiate(dir, dentry, task, NULL); |
diff --git a/include/linux/sched.h b/include/linux/sched.h index f4d969e85612..eb2ae68804aa 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1725,6 +1725,12 @@ static inline int has_group_leader_pid(struct task_struct *p) | |||
1725 | return p->pid == p->tgid; | 1725 | return p->pid == p->tgid; |
1726 | } | 1726 | } |
1727 | 1727 | ||
1728 | static inline | ||
1729 | int same_thread_group(struct task_struct *p1, struct task_struct *p2) | ||
1730 | { | ||
1731 | return p1->tgid == p2->tgid; | ||
1732 | } | ||
1733 | |||
1728 | static inline struct task_struct *next_thread(const struct task_struct *p) | 1734 | static inline struct task_struct *next_thread(const struct task_struct *p) |
1729 | { | 1735 | { |
1730 | return list_entry(rcu_dereference(p->thread_group.next), | 1736 | return list_entry(rcu_dereference(p->thread_group.next), |
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index b53c8fcd9d82..68c96376e84a 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c | |||
@@ -21,8 +21,8 @@ static int check_clock(const clockid_t which_clock) | |||
21 | 21 | ||
22 | read_lock(&tasklist_lock); | 22 | read_lock(&tasklist_lock); |
23 | p = find_task_by_pid(pid); | 23 | p = find_task_by_pid(pid); |
24 | if (!p || (CPUCLOCK_PERTHREAD(which_clock) ? | 24 | if (!p || !(CPUCLOCK_PERTHREAD(which_clock) ? |
25 | p->tgid != current->tgid : p->tgid != pid)) { | 25 | same_thread_group(p, current) : thread_group_leader(p))) { |
26 | error = -EINVAL; | 26 | error = -EINVAL; |
27 | } | 27 | } |
28 | read_unlock(&tasklist_lock); | 28 | read_unlock(&tasklist_lock); |
@@ -308,13 +308,13 @@ int posix_cpu_clock_get(const clockid_t which_clock, struct timespec *tp) | |||
308 | p = find_task_by_pid(pid); | 308 | p = find_task_by_pid(pid); |
309 | if (p) { | 309 | if (p) { |
310 | if (CPUCLOCK_PERTHREAD(which_clock)) { | 310 | if (CPUCLOCK_PERTHREAD(which_clock)) { |
311 | if (p->tgid == current->tgid) { | 311 | if (same_thread_group(p, current)) { |
312 | error = cpu_clock_sample(which_clock, | 312 | error = cpu_clock_sample(which_clock, |
313 | p, &rtn); | 313 | p, &rtn); |
314 | } | 314 | } |
315 | } else { | 315 | } else { |
316 | read_lock(&tasklist_lock); | 316 | read_lock(&tasklist_lock); |
317 | if (p->tgid == pid && p->signal) { | 317 | if (thread_group_leader(p) && p->signal) { |
318 | error = | 318 | error = |
319 | cpu_clock_sample_group(which_clock, | 319 | cpu_clock_sample_group(which_clock, |
320 | p, &rtn); | 320 | p, &rtn); |
@@ -355,7 +355,7 @@ int posix_cpu_timer_create(struct k_itimer *new_timer) | |||
355 | p = current; | 355 | p = current; |
356 | } else { | 356 | } else { |
357 | p = find_task_by_pid(pid); | 357 | p = find_task_by_pid(pid); |
358 | if (p && p->tgid != current->tgid) | 358 | if (p && !same_thread_group(p, current)) |
359 | p = NULL; | 359 | p = NULL; |
360 | } | 360 | } |
361 | } else { | 361 | } else { |
@@ -363,7 +363,7 @@ int posix_cpu_timer_create(struct k_itimer *new_timer) | |||
363 | p = current->group_leader; | 363 | p = current->group_leader; |
364 | } else { | 364 | } else { |
365 | p = find_task_by_pid(pid); | 365 | p = find_task_by_pid(pid); |
366 | if (p && p->tgid != pid) | 366 | if (p && !thread_group_leader(p)) |
367 | p = NULL; | 367 | p = NULL; |
368 | } | 368 | } |
369 | } | 369 | } |
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index d11f579d189a..35b4bbfc78ff 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c | |||
@@ -404,7 +404,7 @@ static struct task_struct * good_sigevent(sigevent_t * event) | |||
404 | 404 | ||
405 | if ((event->sigev_notify & SIGEV_THREAD_ID ) && | 405 | if ((event->sigev_notify & SIGEV_THREAD_ID ) && |
406 | (!(rtn = find_task_by_pid(event->sigev_notify_thread_id)) || | 406 | (!(rtn = find_task_by_pid(event->sigev_notify_thread_id)) || |
407 | rtn->tgid != current->tgid || | 407 | !same_thread_group(rtn, current) || |
408 | (event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL)) | 408 | (event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL)) |
409 | return NULL; | 409 | return NULL; |
410 | 410 | ||
@@ -608,7 +608,7 @@ static struct k_itimer * lock_timer(timer_t timer_id, unsigned long *flags) | |||
608 | spin_lock(&timr->it_lock); | 608 | spin_lock(&timr->it_lock); |
609 | 609 | ||
610 | if ((timr->it_id != timer_id) || !(timr->it_process) || | 610 | if ((timr->it_id != timer_id) || !(timr->it_process) || |
611 | timr->it_process->tgid != current->tgid) { | 611 | !same_thread_group(timr->it_process, current)) { |
612 | spin_unlock(&timr->it_lock); | 612 | spin_unlock(&timr->it_lock); |
613 | spin_unlock_irqrestore(&idr_lock, *flags); | 613 | spin_unlock_irqrestore(&idr_lock, *flags); |
614 | timr = NULL; | 614 | timr = NULL; |
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index b0ace60ce596..7c76f2ffaeaa 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -169,7 +169,7 @@ int ptrace_attach(struct task_struct *task) | |||
169 | retval = -EPERM; | 169 | retval = -EPERM; |
170 | if (task->pid <= 1) | 170 | if (task->pid <= 1) |
171 | goto out; | 171 | goto out; |
172 | if (task->tgid == current->tgid) | 172 | if (same_thread_group(task, current)) |
173 | goto out; | 173 | goto out; |
174 | 174 | ||
175 | repeat: | 175 | repeat: |
diff --git a/kernel/signal.c b/kernel/signal.c index 783b33a0af06..08364e75bb58 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -1150,7 +1150,7 @@ static int kill_something_info(int sig, struct siginfo *info, int pid) | |||
1150 | 1150 | ||
1151 | read_lock(&tasklist_lock); | 1151 | read_lock(&tasklist_lock); |
1152 | for_each_process(p) { | 1152 | for_each_process(p) { |
1153 | if (p->pid > 1 && p->tgid != current->tgid) { | 1153 | if (p->pid > 1 && !same_thread_group(p, current)) { |
1154 | int err = group_send_sig_info(sig, info, p); | 1154 | int err = group_send_sig_info(sig, info, p); |
1155 | ++count; | 1155 | ++count; |
1156 | if (err != -EPERM) | 1156 | if (err != -EPERM) |
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index a7cb4c43fd11..e3778f1215c0 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c | |||
@@ -326,7 +326,7 @@ static int oom_kill_task(struct task_struct *p) | |||
326 | * to memory reserves though, otherwise we might deplete all memory. | 326 | * to memory reserves though, otherwise we might deplete all memory. |
327 | */ | 327 | */ |
328 | do_each_thread(g, q) { | 328 | do_each_thread(g, q) { |
329 | if (q->mm == mm && q->tgid != p->tgid) | 329 | if (q->mm == mm && !same_thread_group(q, p)) |
330 | force_sig(SIGKILL, q); | 330 | force_sig(SIGKILL, q); |
331 | } while_each_thread(g, q); | 331 | } while_each_thread(g, q); |
332 | 332 | ||