* [PATCH] CIFS: reset file mode when CIFS client notices that ATTR_READONLY is no longer set
@ 2007-03-09 20:49 Jeff Layton
2007-03-10 6:06 ` Steve French
0 siblings, 1 reply; 2+ messages in thread
From: Jeff Layton @ 2007-03-09 20:49 UTC (permalink / raw)
To: linux-cifs-client; +Cc: linux-kernel, smfrench
This problem and patch were discovered and written by Alan Tyson of HP, who
asked that I post this. The problem is this:
When the CIFS client mounts a share that does not have Unix extensions, it
will turn off the "w" bits in the file mode if it sees that ATTR_READONLY is
set. It has no corresponding logic, however, to reenable write permissions if
the ATTR_READONLY flag is later removed. This results in a situation where a
file gets "stuck" as read-only. Steps to reproduce this bug are in the
following samba.org BZ:
https://bugzilla.samba.org/show_bug.cgi?id=4443
The patch below corrects this with the following logic:
If unix extensions were not negotiated for the mount, and the server does not
report ATTR_READONLY being set for the file then check the mode bits on the
inode. If no write bits are set, then assume that ATTR_READONLY was previously
set for this file but is not now, and set any write bits allowed by the
mnt_file_mode.
This logic seems reasonable, but I'm not certain that there aren't cases where
it would fall down. Comments and/or ACK's appreciated...
Signed-off-by: Jeff Layton <jlayton@redhat.com>
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 86b9dbb..e75a844 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -494,6 +494,12 @@ int cifs_get_inode_info(struct inode **pinode,
mode e.g. 555 */
if (cifsInfo->cifsAttrs & ATTR_READONLY)
inode->i_mode &= ~(S_IWUGO);
+ else if ((inode->i_mode & S_IWUGO) == 0)
+ /* the ATTR_READONLY flag may have been */
+ /* changed on server -- set any w bits */
+ /* allowed by mnt_file_mode */
+ inode->i_mode |= (S_IWUGO &
+ cifs_sb->mnt_file_mode);
/* BB add code here -
validate if device or weird share or device type? */
}
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 44cfb52..2a374d5 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -219,6 +219,10 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
tmp_inode->i_mode |= S_IFREG;
if (attr & ATTR_READONLY)
tmp_inode->i_mode &= ~(S_IWUGO);
+ else if ((tmp_inode->i_mode & S_IWUGO) == 0)
+ /* the ATTR_READONLY flag may have been changed on */
+ /* server -- set any w bits allowed by mnt_file_mode */
+ tmp_inode->i_mode |= (S_IWUGO & cifs_sb->mnt_file_mode);
} /* could add code here - to validate if device or weird share type? */
/* can not fill in nlink here as in qpathinfo version and Unx search */
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] CIFS: reset file mode when CIFS client notices that ATTR_READONLY is no longer set
2007-03-09 20:49 [PATCH] CIFS: reset file mode when CIFS client notices that ATTR_READONLY is no longer set Jeff Layton
@ 2007-03-10 6:06 ` Steve French
0 siblings, 0 replies; 2+ messages in thread
From: Steve French @ 2007-03-10 6:06 UTC (permalink / raw)
To: Jeff Layton; +Cc: linux-cifs-client, linux-kernel
Jeff Layton wrote:
> This problem and patch were discovered and written by Alan Tyson of HP, who
> asked that I post this. The problem is this:
>
> When the CIFS client mounts a share that does not have Unix extensions, it
> will turn off the "w" bits in the file mode if it sees that ATTR_READONLY is
> set. It has no corresponding logic, however, to reenable write permissions if
> the ATTR_READONLY flag is later removed. This results in a situation where a
> file gets "stuck" as read-only. Steps to reproduce this bug are in the
> following samba.org BZ:
>
> https://bugzilla.samba.org/show_bug.cgi?id=4443
>
> The patch below corrects this with the following logic:
>
> If unix extensions were not negotiated for the mount, and the server does not
> report ATTR_READONLY being set for the file then check the mode bits on the
> inode. If no write bits are set, then assume that ATTR_READONLY was previously
> set for this file but is not now, and set any write bits allowed by the
> mnt_file_mode.
>
> This logic seems reasonable, but I'm not certain that there aren't cases where
> it would fall down. Comments and/or ACK's appreciated...
>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
>
> diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
> index 86b9dbb..e75a844 100644
> --- a/fs/cifs/inode.c
> +++ b/fs/cifs/inode.c
> @@ -494,6 +494,12 @@ int cifs_get_inode_info(struct inode **pinode,
> mode e.g. 555 */
> if (cifsInfo->cifsAttrs & ATTR_READONLY)
> inode->i_mode &= ~(S_IWUGO);
> + else if ((inode->i_mode & S_IWUGO) == 0)
> + /* the ATTR_READONLY flag may have been */
> + /* changed on server -- set any w bits */
> + /* allowed by mnt_file_mode */
> + inode->i_mode |= (S_IWUGO &
> + cifs_sb->mnt_file_mode);
> /* BB add code here -
> validate if device or weird share or device type? */
> }
> diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
> index 44cfb52..2a374d5 100644
> --- a/fs/cifs/readdir.c
> +++ b/fs/cifs/readdir.c
> @@ -219,6 +219,10 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
> tmp_inode->i_mode |= S_IFREG;
> if (attr & ATTR_READONLY)
> tmp_inode->i_mode &= ~(S_IWUGO);
> + else if ((tmp_inode->i_mode & S_IWUGO) == 0)
> + /* the ATTR_READONLY flag may have been changed on */
> + /* server -- set any w bits allowed by mnt_file_mode */
> + tmp_inode->i_mode |= (S_IWUGO & cifs_sb->mnt_file_mode);
> } /* could add code here - to validate if device or weird share type? */
>
> /* can not fill in nlink here as in qpathinfo version and Unx search */
>
>
OK - this is checked in to cifs tree. Let me know if you think it is
important enough to push up at this stage to mainline.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-03-10 6:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-09 20:49 [PATCH] CIFS: reset file mode when CIFS client notices that ATTR_READONLY is no longer set Jeff Layton
2007-03-10 6:06 ` Steve French
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox