Skip to content

Commit

Permalink
proc: task_state: ptrace_parent() doesn't need pid_alive() check
Browse files Browse the repository at this point in the history
p->ptrace != 0 means that release_task(p) was not called, so pid_alive()
buys nothing and we can remove this check.  Other callers already use it
directly without additional checks.

Note: with or without this patch ptrace_parent() can return the pointer to
the freed task, this will be explained/fixed later.

Signed-off-by: Oleg Nesterov <[email protected]>
Cc: Aaron Tomlin <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>,
Cc: Sterling Alexander <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Roland McGrath <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
oleg-nesterov authored and torvalds committed Dec 11, 2014
1 parent b0fafc1 commit abdba6e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions fs/proc/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,18 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
struct user_namespace *user_ns = seq_user_ns(m);
struct group_info *group_info;
int g;
struct task_struct *tracer;
const struct cred *cred;
pid_t ppid, tpid, tgid, ngid;
pid_t ppid, tpid = 0, tgid, ngid;
unsigned int max_fds = 0;

rcu_read_lock();
ppid = pid_alive(p) ?
task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
tpid = 0;
if (pid_alive(p)) {
struct task_struct *tracer = ptrace_parent(p);
if (tracer)
tpid = task_pid_nr_ns(tracer, ns);
}

tracer = ptrace_parent(p);
if (tracer)
tpid = task_pid_nr_ns(tracer, ns);

tgid = task_tgid_nr_ns(p, ns);
ngid = task_numa_group_id(p);
Expand Down

0 comments on commit abdba6e

Please sign in to comment.