summaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2021-02-11 21:04:35 +0100
committerAl Viro <viro@zeniv.linux.org.uk>2021-03-13 04:15:19 +0100
commit4ab5260dab28109979a1b47a8996c9922219927f (patch)
tree05f8487a30f398b3faf014d0d0860aa4108bf769 /fs/cifs
parentgfs2: be careful with inode refresh (diff)
downloadlinux-4ab5260dab28109979a1b47a8996c9922219927f.tar.xz
linux-4ab5260dab28109979a1b47a8996c9922219927f.zip
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: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/dir.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index a3fb81e0ba17..9d7ae93c8af7 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -418,15 +418,16 @@ cifs_create_get_file_info:
if (newinode) {
if (server->ops->set_lease_key)
server->ops->set_lease_key(newinode, fid);
- 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)) {
- newinode->i_uid = current_fsuid();
- if (inode->i_mode & S_ISGID)
- newinode->i_gid = inode->i_gid;
- else
- newinode->i_gid = current_fsgid();
+ if ((*oplock & CIFS_CREATE_ACTION) && S_ISREG(newinode->i_mode)) {
+ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
+ newinode->i_mode = mode;
+ 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;
+ else
+ newinode->i_gid = current_fsgid();
+ }
}
}
}