Commit 4ab5260d authored by Al Viro's avatar Al Viro
Browse files

do_cifs_create(): don't set ->i_mode of something we had not created



If the file had existed before we'd called ->atomic_open() (without
O_EXCL, that is), we have no more business setting ->i_mode than
we would setting ->i_uid or ->i_gid.  We also have no business
doing either if another client has managed to get unlink+mkdir
between ->open() and cifs_inode_get_info().

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 4a378d8a
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -418,10 +418,10 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
		if (newinode) {
			if (server->ops->set_lease_key)
				server->ops->set_lease_key(newinode, fid);
			if ((*oplock & CIFS_CREATE_ACTION) && S_ISREG(newinode->i_mode)) {
				if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
					newinode->i_mode = mode;
			if ((*oplock & CIFS_CREATE_ACTION) &&
			    (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)) {
				if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
					newinode->i_uid = current_fsuid();
					if (inode->i_mode & S_ISGID)
						newinode->i_gid = inode->i_gid;
@@ -430,6 +430,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
				}
			}
		}
	}

cifs_create_set_dentry:
	if (rc != 0) {