Skip to content

Commit 4745880

Browse files
author
Al Viro
committed
procfs: move dropping pde and pid from ->evict_inode() to ->free_inode()
that keeps both around until struct inode is freed, making access to them safe from rcu-pathwalk Acked-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent c1b967d commit 4745880

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

fs/proc/base.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,8 +1878,6 @@ void proc_pid_evict_inode(struct proc_inode *ei)
18781878
hlist_del_init_rcu(&ei->sibling_inodes);
18791879
spin_unlock(&pid->lock);
18801880
}
1881-
1882-
put_pid(pid);
18831881
}
18841882

18851883
struct inode *proc_pid_make_inode(struct super_block *sb,

fs/proc/inode.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,15 @@
3030

3131
static void proc_evict_inode(struct inode *inode)
3232
{
33-
struct proc_dir_entry *de;
3433
struct ctl_table_header *head;
3534
struct proc_inode *ei = PROC_I(inode);
3635

3736
truncate_inode_pages_final(&inode->i_data);
3837
clear_inode(inode);
3938

4039
/* Stop tracking associated processes */
41-
if (ei->pid) {
40+
if (ei->pid)
4241
proc_pid_evict_inode(ei);
43-
ei->pid = NULL;
44-
}
45-
46-
/* Let go of any associated proc directory entry */
47-
de = ei->pde;
48-
if (de) {
49-
pde_put(de);
50-
ei->pde = NULL;
51-
}
5242

5343
head = ei->sysctl;
5444
if (head) {
@@ -80,6 +70,13 @@ static struct inode *proc_alloc_inode(struct super_block *sb)
8070

8171
static void proc_free_inode(struct inode *inode)
8272
{
73+
struct proc_inode *ei = PROC_I(inode);
74+
75+
if (ei->pid)
76+
put_pid(ei->pid);
77+
/* Let go of any associated proc directory entry */
78+
if (ei->pde)
79+
pde_put(ei->pde);
8380
kmem_cache_free(proc_inode_cachep, PROC_I(inode));
8481
}
8582

0 commit comments

Comments
 (0)