]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
procfs: kill ->proc_dops
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 22 Feb 2025 21:04:47 +0000 (16:04 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 11 Jun 2025 02:08:05 +0000 (22:08 -0400)
It has two possible values - one for "forced lookup" entries, another
for the normal ones.  We'd be better off with that as an explicit
flag anyway and in addition to that it opens some fun possibilities
with ->d_op and ->d_flags handling.

[moved PROC_ENTRY_FORCE_LOOKUP to include/linux/proc_fs.h, switched it
to an unused bit - there was a conflict]

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/proc/generic.c
fs/proc/internal.h
include/linux/proc_fs.h

index a3e22803cddf2daab36a3e2dcc9e10c67282b9b4..38ce45ce0eb624ad7a5d8d592ae5af0713ee5e5e 100644 (file)
@@ -254,7 +254,10 @@ struct dentry *proc_lookup_de(struct inode *dir, struct dentry *dentry,
                inode = proc_get_inode(dir->i_sb, de);
                if (!inode)
                        return ERR_PTR(-ENOMEM);
-               d_set_d_op(dentry, de->proc_dops);
+               if (de->flags & PROC_ENTRY_FORCE_LOOKUP)
+                       d_set_d_op(dentry, &proc_net_dentry_ops);
+               else
+                       d_set_d_op(dentry, &proc_misc_dentry_ops);
                return d_splice_alias(inode, dentry);
        }
        read_unlock(&proc_subdir_lock);
@@ -448,9 +451,8 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
        INIT_LIST_HEAD(&ent->pde_openers);
        proc_set_user(ent, (*parent)->uid, (*parent)->gid);
 
-       ent->proc_dops = &proc_misc_dentry_ops;
        /* Revalidate everything under /proc/${pid}/net */
-       if ((*parent)->proc_dops == &proc_net_dentry_ops)
+       if ((*parent)->flags & PROC_ENTRY_FORCE_LOOKUP)
                pde_force_lookup(ent);
 
 out:
index 96122e91c64597b01b9ab0a8f76c7fc7f9efe0ca..a4054916f6dae7d1605faffbe348dd51f20c4142 100644 (file)
@@ -44,7 +44,6 @@ struct proc_dir_entry {
                const struct proc_ops *proc_ops;
                const struct file_operations *proc_dir_ops;
        };
-       const struct dentry_operations *proc_dops;
        union {
                const struct seq_operations *seq_ops;
                int (*single_show)(struct seq_file *, void *);
@@ -403,7 +402,7 @@ extern const struct dentry_operations proc_net_dentry_ops;
 static inline void pde_force_lookup(struct proc_dir_entry *pde)
 {
        /* /proc/net/ entries can be changed under us by setns(CLONE_NEWNET) */
-       pde->proc_dops = &proc_net_dentry_ops;
+       pde->flags |= PROC_ENTRY_FORCE_LOOKUP;
 }
 
 /*
index ea62201c74c4020121225f4ec341341b7a025bbc..de1d24f19f767468dbcbe05ac31fc66f07f55c38 100644 (file)
@@ -27,6 +27,8 @@ enum {
 
        PROC_ENTRY_proc_read_iter       = 1U << 1,
        PROC_ENTRY_proc_compat_ioctl    = 1U << 2,
+
+       PROC_ENTRY_FORCE_LOOKUP         = 1U << 7,
 };
 
 struct proc_ops {