2020-02-10 12:43:22

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH 5.4 303/309] cifs: fix mode bits from dir listing when mounted with modefromsid

From: Aurelien Aptel <[email protected]>

commit e3e056c35108661e418c803adfc054bf683426e7 upstream.

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 <[email protected]>
Signed-off-by: Steve French <[email protected]>
CC: Stable <[email protected]>
Reviewed-by: Pavel Shilovsky <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
fs/cifs/readdir.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -174,7 +174,8 @@ cifs_fill_common_info(struct cifs_fattr
* 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 &&



2020-02-10 19:11:31

by Pavel Shilovskiy

[permalink] [raw]
Subject: RE: [EXTERNAL] [PATCH 5.4 303/309] cifs: fix mode bits from dir listing when mounted with modefromsid


-----Original Message Begin-----
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, February 10, 2020 4:34 AM
To: [email protected]
Cc: Greg Kroah-Hartman <[email protected]>; [email protected]; Aurelien Aptel <[email protected]>; Steven French <[email protected]>; Pavel Shilovskiy <[email protected]>
Subject: [EXTERNAL] [PATCH 5.4 303/309] cifs: fix mode bits from dir listing when mounted with modefromsid

From: Aurelien Aptel <[email protected]>

commit e3e056c35108661e418c803adfc054bf683426e7 upstream.

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 <[email protected]>
Signed-off-by: Steve French <[email protected]>
CC: Stable <[email protected]>
Reviewed-by: Pavel Shilovsky <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
fs/cifs/readdir.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -174,7 +174,8 @@ cifs_fill_common_info(struct cifs_fattr
* 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 &&

-----Original Message End-----

Hi Greg,

This patch fixes the following commit that was introduced in v5.5:

commit fdef665ba44ad5ed154af2acfb19ae2ee3bf5dcc
Author: Steve French <[email protected]>
Date: Fri Dec 6 02:02:38 2019 -0600

smb3: fix mode passed in on create for modetosid mount option


Please remove the patch from all stable trees expect 5.5.y.

--
Best regards,
Pavel Shilovsky

2020-02-10 19:18:27

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [EXTERNAL] [PATCH 5.4 303/309] cifs: fix mode bits from dir listing when mounted with modefromsid

On Mon, Feb 10, 2020 at 07:10:00PM +0000, Pavel Shilovskiy wrote:
>
> -----Original Message Begin-----
> From: Greg Kroah-Hartman <[email protected]>
> Sent: Monday, February 10, 2020 4:34 AM
> To: [email protected]
> Cc: Greg Kroah-Hartman <[email protected]>; [email protected]; Aurelien Aptel <[email protected]>; Steven French <[email protected]>; Pavel Shilovskiy <[email protected]>
> Subject: [EXTERNAL] [PATCH 5.4 303/309] cifs: fix mode bits from dir listing when mounted with modefromsid
>
> From: Aurelien Aptel <[email protected]>
>
> commit e3e056c35108661e418c803adfc054bf683426e7 upstream.
>
> 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 <[email protected]>
> Signed-off-by: Steve French <[email protected]>
> CC: Stable <[email protected]>
> Reviewed-by: Pavel Shilovsky <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
>
> ---
> fs/cifs/readdir.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> --- a/fs/cifs/readdir.c
> +++ b/fs/cifs/readdir.c
> @@ -174,7 +174,8 @@ cifs_fill_common_info(struct cifs_fattr
> * 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 &&
>
> -----Original Message End-----
>
> Hi Greg,
>
> This patch fixes the following commit that was introduced in v5.5:
>
> commit fdef665ba44ad5ed154af2acfb19ae2ee3bf5dcc
> Author: Steve French <[email protected]>
> Date: Fri Dec 6 02:02:38 2019 -0600
>
> smb3: fix mode passed in on create for modetosid mount option
>
>
> Please remove the patch from all stable trees expect 5.5.y.

Now dropped, thanks for letting me know.

greg k-h