Subject: [PATCH] Modify pid_visible to take a pid argument and not a task argument From: Eric W. Biederman Date: 1129748713 -0600 --- fs/proc/array.c | 6 +++--- fs/proc/base.c | 4 ++-- include/linux/pspace.h | 4 ++-- kernel/timer.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) 823513a802c9b991c117baaa07b8784a6e0a607e diff --git a/fs/proc/array.c b/fs/proc/array.c index 59abcf7..4721c5d 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -167,9 +167,9 @@ static inline char * task_state(struct t read_lock(&tasklist_lock); tgid = pid_to_user(p->tgid); pid = pid_to_user(p->pid); - ptgid = pid_alive(p) && pid_visible(p->group_leader->real_parent) ? + ptgid = pid_alive(p) && pid_visible(p->group_leader->real_parent->tgid) ? pid_to_user(p->group_leader->real_parent->tgid) : 0; - tppid = pid_alive(p) && pid_visible(p->parent) && p->ptrace ? + tppid = pid_alive(p) && pid_visible(p->parent->pid) && p->ptrace ? pid_to_user(p->parent->pid) : 0; buffer += sprintf(buffer, "State:\t%s\n" @@ -394,7 +394,7 @@ static int do_task_stat(struct task_stru } it_real_value = task->signal->it_real_value; } - ppid = pid_alive(task) && pid_visible(task->group_leader->real_parent) ? + ppid = pid_alive(task) && pid_visible(task->group_leader->real_parent->tgid) ? pid_to_user(task->group_leader->real_parent->tgid) : 0; read_unlock(&tasklist_lock); diff --git a/fs/proc/base.c b/fs/proc/base.c index d4ccf34..fb5fef8 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2062,7 +2062,7 @@ static int get_tgid_list(int index, unsi int tgid = p->pid; if (!pid_alive(p)) continue; - if (!pid_visible(p)) + if (!pid_visible(p->tgid)) continue; if (--index >= 0) continue; @@ -2093,7 +2093,7 @@ static int get_tid_list(int index, unsig * unlinked task, which cannot be used to access the task-list * via next_thread(). */ - if (pid_alive(task) && pid_visible(task)) do { + if (pid_alive(task) && pid_visible(task->pid)) do { int tid = task->pid; if (--index >= 0) diff --git a/include/linux/pspace.h b/include/linux/pspace.h index 4506670..ab0ed58 100644 --- a/include/linux/pspace.h +++ b/include/linux/pspace.h @@ -44,9 +44,9 @@ static inline int pid_to_user(int pid) return pid - current->pspace->offset; } -static inline int pid_visible(struct task_struct *p) +static inline int pid_visible(int pid) { - int pid = pid_to_user(p->pid); + pid = pid_to_user(pid); return (pid > 0) && (pid < current->pspace->max); } diff --git a/kernel/timer.c b/kernel/timer.c index cdd6080..b7a65e3 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -1024,7 +1024,7 @@ asmlinkage long sys_getppid(void) parent = me->group_leader->real_parent; for (;;) { - pid = pid_visible(parent)? pid_to_user(parent->tgid) : 0; + pid = pid_visible(parent->tgid)? pid_to_user(parent->tgid) : 0; #if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT) { struct task_struct *old = parent; -- 1.0.GIT