Skip to content

Commit 3147d8a

Browse files
committed
proc: Use PIDTYPE_TGID in next_tgid
Combine the pid_task and thes test has_group_leader_pid into a single dereference by using pid_task(PIDTYPE_TGID). This makes the code simpler and proof against needing to even think about any shenanigans that de_thread might get up to. Acked-by: Oleg Nesterov <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 0fb5ce6 commit 3147d8a

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

fs/proc/base.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3359,20 +3359,8 @@ static struct tgid_iter next_tgid(struct pid_namespace *ns, struct tgid_iter ite
33593359
pid = find_ge_pid(iter.tgid, ns);
33603360
if (pid) {
33613361
iter.tgid = pid_nr_ns(pid, ns);
3362-
iter.task = pid_task(pid, PIDTYPE_PID);
3363-
/* What we to know is if the pid we have find is the
3364-
* pid of a thread_group_leader. Testing for task
3365-
* being a thread_group_leader is the obvious thing
3366-
* todo but there is a window when it fails, due to
3367-
* the pid transfer logic in de_thread.
3368-
*
3369-
* So we perform the straight forward test of seeing
3370-
* if the pid we have found is the pid of a thread
3371-
* group leader, and don't worry if the task we have
3372-
* found doesn't happen to be a thread group leader.
3373-
* As we don't care in the case of readdir.
3374-
*/
3375-
if (!iter.task || !has_group_leader_pid(iter.task)) {
3362+
iter.task = pid_task(pid, PIDTYPE_TGID);
3363+
if (!iter.task) {
33763364
iter.tgid += 1;
33773365
goto retry;
33783366
}

0 commit comments

Comments
 (0)