The patch titled Subject: proc: fix /proc/net/* after setns(2) has been added to the -mm tree. Its filename is proc-fix-proc-net-after-setns2.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/proc-fix-proc-net-after-setns2.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/proc-fix-proc-net-after-setns2.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Alexey Dobriyan <adobriyan@xxxxxxxxx> Subject: proc: fix /proc/net/* after setns(2) /proc entries under /proc/net/* can't be cached into dcache because setns(2) can change current net namespace. Link: http://lkml.kernel.org/r/20190107162336.GA9239@avx2 Fixes: 1da4d377f943fe4194ffb9fb9c26cc58fad4dd24 ("proc: revalidate misc dentries") Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx> Reported-by: Mateusz Stępień <mateusz.stepien@xxxxxxxxxxxxx> Reported-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- --- a/fs/proc/generic.c~proc-fix-proc-net-after-setns2 +++ a/fs/proc/generic.c @@ -256,7 +256,7 @@ struct dentry *proc_lookup_de(struct ino inode = proc_get_inode(dir->i_sb, de); if (!inode) return ERR_PTR(-ENOMEM); - d_set_d_op(dentry, &proc_misc_dentry_ops); + d_set_d_op(dentry, de->proc_dops); return d_splice_alias(inode, dentry); } read_unlock(&proc_subdir_lock); @@ -429,6 +429,8 @@ static struct proc_dir_entry *__proc_cre INIT_LIST_HEAD(&ent->pde_openers); proc_set_user(ent, (*parent)->uid, (*parent)->gid); + ent->proc_dops = &proc_misc_dentry_ops; + out: return ent; } --- a/fs/proc/internal.h~proc-fix-proc-net-after-setns2 +++ a/fs/proc/internal.h @@ -44,6 +44,7 @@ struct proc_dir_entry { struct completion *pde_unload_completion; const struct inode_operations *proc_iops; const struct file_operations *proc_fops; + const struct dentry_operations *proc_dops; union { const struct seq_operations *seq_ops; int (*single_show)(struct seq_file *, void *); --- a/fs/proc/proc_net.c~proc-fix-proc-net-after-setns2 +++ a/fs/proc/proc_net.c @@ -38,6 +38,12 @@ static struct net *get_proc_net(const st return maybe_get_net(PDE_NET(PDE(inode))); } +static void pde_force_lookup(struct proc_dir_entry *pde) +{ + // /proc/net/* can be changed under us by setns(CLONE_NEWNET) + pde->proc_dops = &simple_dentry_operations; +} + static int seq_open_net(struct inode *inode, struct file *file) { unsigned int state_size = PDE(inode)->state_size; @@ -90,6 +96,7 @@ struct proc_dir_entry *proc_create_net_d p = proc_create_reg(name, mode, &parent, data); if (!p) return NULL; + pde_force_lookup(p); p->proc_fops = &proc_net_seq_fops; p->seq_ops = ops; p->state_size = state_size; @@ -133,6 +140,7 @@ struct proc_dir_entry *proc_create_net_d p = proc_create_reg(name, mode, &parent, data); if (!p) return NULL; + pde_force_lookup(p); p->proc_fops = &proc_net_seq_fops; p->seq_ops = ops; p->state_size = state_size; @@ -181,6 +189,7 @@ struct proc_dir_entry *proc_create_net_s p = proc_create_reg(name, mode, &parent, data); if (!p) return NULL; + pde_force_lookup(p); p->proc_fops = &proc_net_single_fops; p->single_show = show; return proc_register(parent, p); @@ -223,6 +232,7 @@ struct proc_dir_entry *proc_create_net_s p = proc_create_reg(name, mode, &parent, data); if (!p) return NULL; + pde_force_lookup(p); p->proc_fops = &proc_net_single_fops; p->single_show = show; p->write = write; _ Patches currently in -mm which might be from adobriyan@xxxxxxxxx are proc-fix-proc-net-after-setns2.patch