Restrict clearing TIF_SIGPENDING
[safe/jmp/linux-2.6] / kernel / pid.c
index 1d9cc26..eb66bd2 100644 (file)
 #include <linux/bootmem.h>
 #include <linux/hash.h>
 #include <linux/pid_namespace.h>
+#include <linux/init_task.h>
 
 #define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
 static struct hlist_head *pid_hash;
 static int pidhash_shift;
 static struct kmem_cache *pid_cachep;
+struct pid init_struct_pid = INIT_STRUCT_PID;
 
 int pid_max = PID_MAX_DEFAULT;
 
@@ -65,7 +67,8 @@ struct pid_namespace init_pid_ns = {
        .pidmap = {
                [ 0 ... PIDMAP_ENTRIES-1] = { ATOMIC_INIT(BITS_PER_PAGE), NULL }
        },
-       .last_pid = 0
+       .last_pid = 0,
+       .child_reaper = &init_task
 };
 
 /*
@@ -196,7 +199,7 @@ fastcall void free_pid(struct pid *pid)
        hlist_del_rcu(&pid->pid_chain);
        spin_unlock_irqrestore(&pidmap_lock, flags);
 
-       free_pidmap(current->nsproxy->pid_ns, pid->nr);
+       free_pidmap(&init_pid_ns, pid->nr);
        call_rcu(&pid->rcu, delayed_put_pid);
 }
 
@@ -246,13 +249,16 @@ struct pid * fastcall find_pid(int nr)
 }
 EXPORT_SYMBOL_GPL(find_pid);
 
-int fastcall attach_pid(struct task_struct *task, enum pid_type type, int nr)
+/*
+ * attach_pid() must be called with the tasklist_lock write-held.
+ */
+int fastcall attach_pid(struct task_struct *task, enum pid_type type,
+               struct pid *pid)
 {
        struct pid_link *link;
-       struct pid *pid;
 
        link = &task->pids[type];
-       link->pid = pid = find_pid(nr);
+       link->pid = pid;
        hlist_add_head_rcu(&link->node, &pid->tasks[type]);
 
        return 0;
@@ -359,16 +365,11 @@ struct pid *find_ge_pid(int nr)
 }
 EXPORT_SYMBOL_GPL(find_get_pid);
 
-int copy_pid_ns(int flags, struct task_struct *tsk)
+struct pid_namespace *copy_pid_ns(int flags, struct pid_namespace *old_ns)
 {
-       struct pid_namespace *old_ns = tsk->nsproxy->pid_ns;
-       int err = 0;
-
-       if (!old_ns)
-               return 0;
-
+       BUG_ON(!old_ns);
        get_pid_ns(old_ns);
-       return err;
+       return old_ns;
 }
 
 void free_pid_ns(struct kref *kref)
@@ -411,7 +412,5 @@ void __init pidmap_init(void)
        set_bit(0, init_pid_ns.pidmap[0].page);
        atomic_dec(&init_pid_ns.pidmap[0].nr_free);
 
-       pid_cachep = kmem_cache_create("pid", sizeof(struct pid),
-                                       __alignof__(struct pid),
-                                       SLAB_PANIC, NULL, NULL);
+       pid_cachep = KMEM_CACHE(pid, SLAB_PANIC);
 }