[PATCH 04/11] fuse: fix O_EXCL in fuse_atomic_open()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Miklos Szeredi <mszeredi@xxxxxxx>

If open flags has O_EXCL and dentry is positive after lookup then return
-EEXIST instead of "1".

This bug resulted in some O_EXCL opens succeeding (on a cache miss) despite
the file already existing.

Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
---
 fs/fuse/dir.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 62b43b5..694ec6b 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -523,9 +523,17 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
 			entry = res;
 	}
 
-	if (!(flags & O_CREAT) || entry->d_inode)
+	if (!(flags & O_CREAT))
 		goto no_open;
 
+	if (entry->d_inode) {
+		err = -EEXIST;
+		if (flags & O_EXCL)
+			goto out_dput;
+
+		goto no_open;
+	}
+
 	/* Only creates */
 	*opened |= FILE_CREATED;
 
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux