Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / kernel / pid.c
index eeb836b..5eeb505 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/init.h>
 #include <linux/bootmem.h>
 #include <linux/hash.h>
+#include <linux/vs_cvirt.h>
 
 #define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
 static struct hlist_head *pid_hash;
@@ -218,7 +219,7 @@ struct pid * fastcall find_pid(int nr)
        return NULL;
 }
 
-int fastcall attach_pid(task_t *task, enum pid_type type, int nr)
+int fastcall attach_pid(struct task_struct *task, enum pid_type type, int nr)
 {
        struct pid_link *link;
        struct pid *pid;
@@ -233,7 +234,7 @@ int fastcall attach_pid(task_t *task, enum pid_type type, int nr)
        return 0;
 }
 
-void fastcall detach_pid(task_t *task, enum pid_type type)
+void fastcall detach_pid(struct task_struct *task, enum pid_type type)
 {
        struct pid_link *link;
        struct pid *pid;
@@ -260,6 +261,14 @@ struct task_struct * fastcall pid_task(struct pid *pid, enum pid_type type)
                first = rcu_dereference(pid->tasks[type].first);
                if (first)
                        result = hlist_entry(first, struct task_struct, pids[(type)].node);
+               if (result && (pid->nr != 1) &&
+                       !vx_check(vx_task_xid(result), VX_WATCH|VX_ADMIN|VX_IDENT)) {
+                       vxwprintk((type == PIDTYPE_PID) && (current->xid),
+                               "pid_task(%d,%d): task %p[#%u,%u] did lookup %p[#%u,%u]",
+                               pid->nr, type, current, vx_current_xid(), current->pid,
+                               result, vx_task_xid(result), result->pid);
+                       result = NULL;
+               }
        }
        return result;
 }
@@ -267,8 +276,12 @@ struct task_struct * fastcall pid_task(struct pid *pid, enum pid_type type)
 /*
  * Must be called under rcu_read_lock() or with tasklist_lock read-held.
  */
-task_t *find_task_by_pid_type(int type, int nr)
+struct task_struct *find_task_by_pid_type(int type, int nr)
 {
+       if (type == PIDTYPE_PID)
+               nr = vx_rmap_pid(nr);
+       else if (type == PIDTYPE_REALPID)
+               type = PIDTYPE_PID;
        return pid_task(find_pid(nr), type);
 }