From 950ab972348e5627b401b39e0fda2f330f487596 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Tue, 21 Dec 2021 00:13:39 +0000 Subject: [PATCH] UPSTREAM: ANDROID: fuse-bpf: Close backing fds in fuse_dentry_revalidate Bug: 202785178 Test: fuse_test runs, no leak on Android Signed-off-by: Paul Lawrence Change-Id: If3c8dbe680f21c646e98f66140b842869c2c5abf --- fs/fuse/dir.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index df8381ff0738..b1da68b09456 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -237,6 +237,15 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) &entry->d_name, &outarg, &bpf_outarg); ret = fuse_simple_request(fm, &args); dput(parent); + + /* + * TODO This doesn't seem sufficient, though we don't plan to + * change the backing file ever, so not sure what is correct + * here yet, especially as we can't return an error to user + */ + if (bpf_outarg.backing_action == FUSE_ACTION_REPLACE) + __close_fd(fm->fc->task->files, bpf_outarg.backing_fd); + /* Zero nodeid is same as -ENOENT */ if (!ret && !outarg.nodeid) ret = -ENOENT;