From 1bbc55131e59bd099fdc568d3aa0b42634dbd188 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 2 May 2018 21:26:16 -0400 Subject: procfs: get rid of ancient BS in pid_revalidate() uses First of all, calling pid_revalidate() in the end of /* lookups is *not* about closing any kind of races; that used to be true once upon a time, but these days those comments are actively misleading. Especially since pid_revalidate() doesn't even do d_drop() on failure anymore. It doesn't matter, anyway, since once pid_revalidate() starts returning false, ->d_delete() of those dentries starts saying "don't keep"; they won't get stuck in dcache any longer than they are pinned. These calls cannot be just removed, though - the side effect of pid_revalidate() (updating i_uid/i_gid/etc.) is what we are calling it for here. Let's separate the "update ownership" into a new helper (pid_update_inode()) and use it, both in lookups and in pid_revalidate() itself. The comments in pid_revalidate() are also out of date - they refer to the time when pid_revalidate() used to call d_drop() directly... Signed-off-by: Al Viro --- fs/proc/namespaces.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'fs/proc/namespaces.c') diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c index 59b17e509f46..ad1adce6541d 100644 --- a/fs/proc/namespaces.c +++ b/fs/proc/namespaces.c @@ -96,19 +96,16 @@ static int proc_ns_instantiate(struct inode *dir, inode = proc_pid_make_inode(dir->i_sb, task, S_IFLNK | S_IRWXUGO); if (!inode) - goto out; + return -ENOENT; ei = PROC_I(inode); inode->i_op = &proc_ns_link_inode_operations; ei->ns_ops = ns_ops; + pid_update_inode(task, inode); d_set_d_op(dentry, &pid_dentry_operations); d_add(dentry, inode); - /* Close the race of the process dying before we return the dentry */ - if (pid_revalidate(dentry, 0)) - return 0; -out: - return -ENOENT; + return 0; } static int proc_ns_dir_readdir(struct file *file, struct dir_context *ctx) -- cgit v1.2.3