* [PATCH] cifs: fix mode bits from dir listing when mounted with modefromsid
@ 2020-02-06 17:16 Aurelien Aptel
2020-02-06 18:23 ` Pavel Shilovsky
0 siblings, 1 reply; 3+ messages in thread
From: Aurelien Aptel @ 2020-02-06 17:16 UTC (permalink / raw)
To: linux-cifs; +Cc: smfrench, Aurelien Aptel
When mounting with -o modefromsid, the mode bits are stored in an
ACE. Directory enumeration (e.g. ls -l /mnt) triggers an SMB Query Dir
which does not include ACEs in its response. The mode bits in this
case are silently set to a default value of 755 instead.
This patch marks the dentry created during the directory enumeration
as needing re-evaluation (i.e. additional Query Info with ACEs) so
that the mode bits can be properly extracted.
Quick repro:
$ mount.cifs //win19.test/data /mnt -o ...,modefromsid
$ touch /mnt/foo && chmod 751 /mnt/foo
$ stat /mnt/foo
# reports 751 (OK)
$ sleep 2
# dentry older than 1s by default get invalidated
$ ls -l /mnt
# since dentry invalid, ls does a Query Dir
# and reports foo as 755 (WRONG)
Signed-off-by: Aurelien Aptel <aaptel@suse.com>
---
fs/cifs/readdir.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index d17587c2c4ab..ba9dadf3be24 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -196,7 +196,8 @@ cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)
* may look wrong since the inodes may not have timed out by the time
* "ls" does a stat() call on them.
*/
- if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
+ if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) ||
+ (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID))
fattr->cf_flags |= CIFS_FATTR_NEED_REVAL;
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL &&
--
2.16.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cifs: fix mode bits from dir listing when mounted with modefromsid
2020-02-06 17:16 [PATCH] cifs: fix mode bits from dir listing when mounted with modefromsid Aurelien Aptel
@ 2020-02-06 18:23 ` Pavel Shilovsky
2020-02-06 18:42 ` Steve French
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Shilovsky @ 2020-02-06 18:23 UTC (permalink / raw)
To: Aurelien Aptel; +Cc: linux-cifs, Steve French
чт, 6 февр. 2020 г. в 09:17, Aurelien Aptel <aaptel@suse.com>:
>
> When mounting with -o modefromsid, the mode bits are stored in an
> ACE. Directory enumeration (e.g. ls -l /mnt) triggers an SMB Query Dir
> which does not include ACEs in its response. The mode bits in this
> case are silently set to a default value of 755 instead.
>
> This patch marks the dentry created during the directory enumeration
> as needing re-evaluation (i.e. additional Query Info with ACEs) so
> that the mode bits can be properly extracted.
>
> Quick repro:
>
> $ mount.cifs //win19.test/data /mnt -o ...,modefromsid
> $ touch /mnt/foo && chmod 751 /mnt/foo
> $ stat /mnt/foo
> # reports 751 (OK)
> $ sleep 2
> # dentry older than 1s by default get invalidated
> $ ls -l /mnt
> # since dentry invalid, ls does a Query Dir
> # and reports foo as 755 (WRONG)
>
> Signed-off-by: Aurelien Aptel <aaptel@suse.com>
> ---
> fs/cifs/readdir.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
> index d17587c2c4ab..ba9dadf3be24 100644
> --- a/fs/cifs/readdir.c
> +++ b/fs/cifs/readdir.c
> @@ -196,7 +196,8 @@ cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)
> * may look wrong since the inodes may not have timed out by the time
> * "ls" does a stat() call on them.
> */
> - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
> + if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) ||
> + (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID))
> fattr->cf_flags |= CIFS_FATTR_NEED_REVAL;
>
> if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL &&
> --
> 2.16.4
>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
This patch needs stable tag since "modefromsid" was introduced in v5.5.
--
Best regards,
Pavel Shilovsky
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cifs: fix mode bits from dir listing when mounted with modefromsid
2020-02-06 18:23 ` Pavel Shilovsky
@ 2020-02-06 18:42 ` Steve French
0 siblings, 0 replies; 3+ messages in thread
From: Steve French @ 2020-02-06 18:42 UTC (permalink / raw)
To: Pavel Shilovsky; +Cc: Aurelien Aptel, linux-cifs
I added stable already - will add your reviewed by as well. thx
On Thu, Feb 6, 2020 at 12:24 PM Pavel Shilovsky <piastryyy@gmail.com> wrote:
>
> чт, 6 февр. 2020 г. в 09:17, Aurelien Aptel <aaptel@suse.com>:
> >
> > When mounting with -o modefromsid, the mode bits are stored in an
> > ACE. Directory enumeration (e.g. ls -l /mnt) triggers an SMB Query Dir
> > which does not include ACEs in its response. The mode bits in this
> > case are silently set to a default value of 755 instead.
> >
> > This patch marks the dentry created during the directory enumeration
> > as needing re-evaluation (i.e. additional Query Info with ACEs) so
> > that the mode bits can be properly extracted.
> >
> > Quick repro:
> >
> > $ mount.cifs //win19.test/data /mnt -o ...,modefromsid
> > $ touch /mnt/foo && chmod 751 /mnt/foo
> > $ stat /mnt/foo
> > # reports 751 (OK)
> > $ sleep 2
> > # dentry older than 1s by default get invalidated
> > $ ls -l /mnt
> > # since dentry invalid, ls does a Query Dir
> > # and reports foo as 755 (WRONG)
> >
> > Signed-off-by: Aurelien Aptel <aaptel@suse.com>
> > ---
> > fs/cifs/readdir.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
> > index d17587c2c4ab..ba9dadf3be24 100644
> > --- a/fs/cifs/readdir.c
> > +++ b/fs/cifs/readdir.c
> > @@ -196,7 +196,8 @@ cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)
> > * may look wrong since the inodes may not have timed out by the time
> > * "ls" does a stat() call on them.
> > */
> > - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
> > + if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) ||
> > + (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID))
> > fattr->cf_flags |= CIFS_FATTR_NEED_REVAL;
> >
> > if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL &&
> > --
> > 2.16.4
> >
>
> Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
>
> This patch needs stable tag since "modefromsid" was introduced in v5.5.
>
> --
> Best regards,
> Pavel Shilovsky
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-06 18:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-06 17:16 [PATCH] cifs: fix mode bits from dir listing when mounted with modefromsid Aurelien Aptel
2020-02-06 18:23 ` Pavel Shilovsky
2020-02-06 18:42 ` Steve French
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).