[linux-cifs-client] [PATCH] [CIFS] use mount file_mode/dir_mode exclusively on mount without unix extensions

Jeff Layton jlayton at redhat.com
Mon Sep 24 13:48:01 GMT 2007


When CIFS creates a new inode on a mount without unix extensions, it
temporarily assigns the mode that was passed to it in the create/mkdir
call. Eventually, when the inode is revalidated, it changes to have the
file_mode or dir_mode for the mount. This is confusing to users who
expect that the mode shouldn't change this way. It's also problematic
since only the mode is treated this way, not the uid or gid. Suppose you
have a CIFS mount that's mounted with:

uid=0,gid=0,file_mode=0666,dir_mode=0777

..if an unprivileged user comes along and does this on the mount:

mkdir -m 0700 foo
touch foo/bar

..there is a period of time where the touch will fail, since the dir
will initially be owned by root and have mode 0700. If the user waits
long enough, then "foo" will be revalidated and will get the correct
dir_mode permissions.

This patch changes cifs_mkdir and cifs_create to not overwrite the
mode found by the initial cifs_get_inode_info call after the inode is
created on the server.

Signed-off-by: Jeff Layton <jlayton at redhat.com>
---
 fs/cifs/dir.c   |    1 -
 fs/cifs/inode.c |    2 --
 2 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index db5287a..777814b 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -242,7 +242,6 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
 			rc = cifs_get_inode_info(&newinode, full_path,
 						 buf, inode->i_sb, xid);
 			if (newinode) {
-				newinode->i_mode = mode;
 				if ((oplock & CIFS_CREATE_ACTION) &&
 				    (cifs_sb->mnt_cifs_flags &
 				     CIFS_MOUNT_SET_UID)) {
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 552d68b..ae22abf 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1030,8 +1030,6 @@ mkdir_get_info:
 			   eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode,
 						 -1, -1, local_nls); */
 			if (direntry->d_inode) {
-				direntry->d_inode->i_mode = mode;
-				direntry->d_inode->i_mode |= S_IFDIR;
 				if (cifs_sb->mnt_cifs_flags &
 				     CIFS_MOUNT_SET_UID) {
 					direntry->d_inode->i_uid =
-- 
1.5.2.1



More information about the linux-cifs-client mailing list