From 65d60dffad0bffba938260552d0f9c5341a7c130 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Tue, 25 Jul 2023 11:20:11 -0700 Subject: [PATCH] UPSTREAM: ANDROID: fuse-bpf: Use stored bpf for create_open create_open would always take its parent directory's bpf for the created object. Modify to use the bpf stored in fuse_dentry which is set by lookup. Bug: 291705489 Test: fuse_test passes, adb push file /sdcard/Android/data works Signed-off-by: Paul Lawrence Change-Id: I0a1ea2a291a8fdf67923f1827176b2ea96bd4c2d --- fs/fuse/backing.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c index 770b6f07f443..731d0336baab 100644 --- a/fs/fuse/backing.c +++ b/fs/fuse/backing.c @@ -261,6 +261,7 @@ int fuse_create_open_backing( struct file *file, unsigned int flags, umode_t mode) { struct fuse_inode *dir_fuse_inode = get_fuse_inode(dir); + struct fuse_dentry *fuse_entry = get_fuse_dentry(entry); struct fuse_dentry *dir_fuse_dentry = get_fuse_dentry(entry->d_parent); struct dentry *backing_dentry = NULL; struct inode *inode = NULL; @@ -292,19 +293,19 @@ int fuse_create_open_backing( if (err) goto out; - if (get_fuse_dentry(entry)->backing_path.dentry) - path_put(&get_fuse_dentry(entry)->backing_path); - get_fuse_dentry(entry)->backing_path = (struct path) { + if (fuse_entry->backing_path.dentry) + path_put(&fuse_entry->backing_path); + fuse_entry->backing_path = (struct path) { .mnt = dir_fuse_dentry->backing_path.mnt, .dentry = backing_dentry, }; - path_get(&get_fuse_dentry(entry)->backing_path); + path_get(&fuse_entry->backing_path); if (d_inode) target_nodeid = get_fuse_inode(d_inode)->nodeid; inode = fuse_iget_backing(dir->i_sb, target_nodeid, - get_fuse_dentry(entry)->backing_path.dentry->d_inode); + fuse_entry->backing_path.dentry->d_inode); if (!inode) { err = -EIO; goto out; @@ -312,9 +313,8 @@ int fuse_create_open_backing( if (get_fuse_inode(inode)->bpf) bpf_prog_put(get_fuse_inode(inode)->bpf); - get_fuse_inode(inode)->bpf = dir_fuse_inode->bpf; - if (get_fuse_inode(inode)->bpf) - bpf_prog_inc(dir_fuse_inode->bpf); + get_fuse_inode(inode)->bpf = fuse_entry->bpf; + fuse_entry->bpf = NULL; newent = d_splice_alias(inode, entry); if (IS_ERR(newent)) {