]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
convert bpf
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 9 May 2024 16:26:53 +0000 (12:26 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 16 Nov 2025 06:35:03 +0000 (01:35 -0500)
object creation goes through the normal VFS paths or approximation
thereof (user_path_create()/done_path_create() in case of bpf_obj_do_pin(),
open-coded simple_{start,done}_creating() in bpf_iter_link_pin_kernel()
at mount time), removals go entirely through the normal VFS paths (and
->unlink() is simple_unlink() there).

Enough to have bpf_dentry_finalize() use d_make_persistent() instead
of dget() and we are done.

Convert bpf_iter_link_pin_kernel() to simple_{start,done}_creating(),
while we are at it.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
kernel/bpf/inode.c

index 81780bcf8d2544ed3d734081ce021038134278e0..9f866a010dada8aeb99e4dfb865590c57cce5ecd 100644 (file)
@@ -144,8 +144,7 @@ static int bpf_inode_type(const struct inode *inode, enum bpf_type *type)
 static void bpf_dentry_finalize(struct dentry *dentry, struct inode *inode,
                                struct inode *dir)
 {
-       d_instantiate(dentry, inode);
-       dget(dentry);
+       d_make_persistent(dentry, inode);
 
        inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
 }
@@ -420,16 +419,12 @@ static int bpf_iter_link_pin_kernel(struct dentry *parent,
        struct dentry *dentry;
        int ret;
 
-       inode_lock(parent->d_inode);
-       dentry = lookup_noperm(&QSTR(name), parent);
-       if (IS_ERR(dentry)) {
-               inode_unlock(parent->d_inode);
+       dentry = simple_start_creating(parent, name);
+       if (IS_ERR(dentry))
                return PTR_ERR(dentry);
-       }
        ret = bpf_mkobj_ops(dentry, mode, link, &bpf_link_iops,
                            &bpf_iter_fops);
-       dput(dentry);
-       inode_unlock(parent->d_inode);
+       simple_done_creating(dentry);
        return ret;
 }
 
@@ -1080,7 +1075,7 @@ static void bpf_kill_super(struct super_block *sb)
 {
        struct bpf_mount_opts *opts = sb->s_fs_info;
 
-       kill_litter_super(sb);
+       kill_anon_super(sb);
        kfree(opts);
 }