Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

Al Viro 47458802 c1b967d0

+8 -13
-2
fs/proc/base.c
··· 1878 1878 hlist_del_init_rcu(&ei->sibling_inodes); 1879 1879 spin_unlock(&pid->lock); 1880 1880 } 1881 - 1882 - put_pid(pid); 1883 1881 } 1884 1882 1885 1883 struct inode *proc_pid_make_inode(struct super_block *sb,
+8 -11
fs/proc/inode.c
··· 30 30 31 31 static void proc_evict_inode(struct inode *inode) 32 32 { 33 - struct proc_dir_entry *de; 34 33 struct ctl_table_header *head; 35 34 struct proc_inode *ei = PROC_I(inode); 36 35 ··· 37 38 clear_inode(inode); 38 39 39 40 /* Stop tracking associated processes */ 40 - if (ei->pid) { 41 + if (ei->pid) 41 42 proc_pid_evict_inode(ei); 42 - ei->pid = NULL; 43 - } 44 - 45 - /* Let go of any associated proc directory entry */ 46 - de = ei->pde; 47 - if (de) { 48 - pde_put(de); 49 - ei->pde = NULL; 50 - } 51 43 52 44 head = ei->sysctl; 53 45 if (head) { ··· 70 80 71 81 static void proc_free_inode(struct inode *inode) 72 82 { 83 + struct proc_inode *ei = PROC_I(inode); 84 + 85 + if (ei->pid) 86 + put_pid(ei->pid); 87 + /* Let go of any associated proc directory entry */ 88 + if (ei->pde) 89 + pde_put(ei->pde); 73 90 kmem_cache_free(proc_inode_cachep, PROC_I(inode)); 74 91 } 75 92