smb3: fix incorrect mode displayed for read-only files
authorSteve French <stfrench@microsoft.com>
Sun, 22 Sep 2024 04:28:32 +0000 (23:28 -0500)
committerSteve French <stfrench@microsoft.com>
Wed, 25 Sep 2024 02:51:48 +0000 (21:51 -0500)
commit2f3017e7cc7515e0110a3733d8dca84de2a1d23d
treefefd429e787938e318422ae8b2e6599231c6bd69
parent663f295e35594f4c2584fc68c28546b747b637cd
smb3: fix incorrect mode displayed for read-only files

Commands like "chmod 0444" mark a file readonly via the attribute flag
(when mapping of mode bits into the ACL are not set, or POSIX extensions
are not negotiated), but they were not reported correctly for stat of
directories (they were reported ok for files and for "ls").  See example
below:

    root:~# ls /mnt2 -l
    total 12
    drwxr-xr-x 2 root root         0 Sep 21 18:03 normaldir
    -rwxr-xr-x 1 root root         0 Sep 21 23:24 normalfile
    dr-xr-xr-x 2 root root         0 Sep 21 17:55 readonly-dir
    -r-xr-xr-x 1 root root 209716224 Sep 21 18:15 readonly-file
    root:~# stat -c %a /mnt2/readonly-dir
    755
    root:~# stat -c %a /mnt2/readonly-file
    555

This fixes the stat of directories when ATTR_READONLY is set
(in cases where the mode can not be obtained other ways).

    root:~# stat -c %a /mnt2/readonly-dir
    555

Cc: stable@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/inode.c