[PATCH 03/11] 9p: fix O_EXCL in v9fs_vfs_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: Eric Van Hensbergen <ericvh@xxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
---
 fs/9p/vfs_inode.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 94de6d1..915cea5 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -863,8 +863,15 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
 	}
 
 	/* Only creates */
-	if (!(flags & O_CREAT) || dentry->d_inode)
+	if (!(flags & O_CREAT)) {
 		return finish_no_open(file, res);
+	} else {
+		err = -EEXIST;
+		if (flags & O_EXCL)
+			goto out;
+
+		return finish_no_open(file, res);
+	}
 
 	err = 0;
 	fid = NULL;
-- 
1.8.1.4

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




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]