summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorManfred Spraul <manfred@colorfullife.com>2004-12-02 15:47:45 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-12-02 15:47:45 -0800
commit01eb4811efe377ac2311329186e61f2392dee75c (patch)
tree1f761749ea731aeb917ee25669ca2d7c90613b57 /include/linux
parentdfecb2536027830170e587712c5a4b1ccfbd544e (diff)
[PATCH] proc_pid_status() oops fix
proc_pid_status dereferences pointers in the task structure even if the task is already dead. This is probably the reason for the oops described in http://bugme.osdl.org/show_bug.cgi?id=3812 The attached patch removes the pointer dereferences by using pid_alive() for testing that the task structure contents is still valid before dereferencing them. The task structure itself is guaranteed to be valid - we hold a reference count. Signed-Off-By: Manfred Spraul <manfred@colorfullife.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/sched.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 0c8262c6d6b8..440393fcd5c7 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -671,6 +671,19 @@ static inline pid_t process_group(struct task_struct *tsk)
return tsk->signal->pgrp;
}
+/**
+ * pid_alive - check that a task structure is not stale
+ * @p: Task structure to be checked.
+ *
+ * Test if a process is not yet dead (at most zombie state)
+ * If pid_alive fails, then pointers within the task structure
+ * can be stale and must not be dereferenced.
+ */
+static inline int pid_alive(struct task_struct *p)
+{
+ return p->pids[PIDTYPE_PID].nr != 0;
+}
+
extern void free_task(struct task_struct *tsk);
extern void __put_task_struct(struct task_struct *tsk);
#define get_task_struct(tsk) do { atomic_inc(&(tsk)->usage); } while(0)