From 3a772729dddbfd427dff48a44b0d7dd0bb4addc3 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Wed, 11 Nov 2020 17:22:32 +0100 Subject: [PATCH] BACKPORT: fuse: always revalidate if exclusive create commit df8629af293493757beccac2d3168fe5a315636e upstream. Failure to do so may result in EEXIST even if the file only exists in the cache and not in the filesystem. The atomic nature of O_EXCL mandates that the cached state should be ignored and existence verified anew. Reported-by: Ken Schalk Change-Id: I7bc67048363004f94dfe7b74d0873c019f06eaef Signed-off-by: Miklos Szeredi Signed-off-by: Wu Bo Signed-off-by: Greg Kroah-Hartman --- fs/fuse/dir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 6071e12dbd6c..59c36841e86a 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -231,7 +231,6 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) inode = d_inode_rcu(entry); if (inode && fuse_is_bad(inode)) goto invalid; - #ifdef CONFIG_FUSE_BPF /* TODO: Do we need bpf support for revalidate? * If the lower filesystem says the entry is invalid, FUSE probably shouldn't @@ -245,7 +244,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) } #endif if (time_before64(fuse_dentry_time(entry), get_jiffies_64()) || - (flags & LOOKUP_REVAL)) { + (flags & (LOOKUP_EXCL | LOOKUP_REVAL))) { struct fuse_entry_out outarg; struct fuse_entry_bpf bpf_arg; FUSE_ARGS(args);