proc: Fix Oops on stat of /proc/<zombie pid>/ns/net
authorEric W. Biederman <ebiederm@xmission.com>
Wed, 15 Jun 2011 19:47:04 +0000 (12:47 -0700)
committerEric W. Biederman <ebiederm@xmission.com>
Wed, 15 Jun 2011 21:35:29 +0000 (14:35 -0700)
Don't call iput with the inode half setup to be a namespace filedescriptor.
Instead rearrange the code so that we don't initialize ei->ns_ops until
after I ns_ops->get succeeds, preventing us from invoking ns_ops->put
when ns_ops->get failed.

Reported-by: Ingo Saitz <Ingo.Saitz@stud.uni-hannover.de>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
fs/proc/namespaces.c

index 781dec5bd682c30435c852c98d08814f2a511f93..be177f702acbc9bc352c0e13f5b37aeedbf6dd25 100644 (file)
@@ -38,18 +38,21 @@ static struct dentry *proc_ns_instantiate(struct inode *dir,
        struct inode *inode;
        struct proc_inode *ei;
        struct dentry *error = ERR_PTR(-ENOENT);
+       void *ns;
 
        inode = proc_pid_make_inode(dir->i_sb, task);
        if (!inode)
                goto out;
 
+       ns = ns_ops->get(task);
+       if (!ns)
+               goto out_iput;
+
        ei = PROC_I(inode);
        inode->i_mode = S_IFREG|S_IRUSR;
        inode->i_fop  = &ns_file_operations;
        ei->ns_ops    = ns_ops;
-       ei->ns        = ns_ops->get(task);
-       if (!ei->ns)
-               goto out_iput;
+       ei->ns        = ns;
 
        dentry->d_op = &pid_dentry_operations;
        d_add(dentry, inode);