public inbox for linux-cifs@vger.kernel.org
 help / color / mirror / Atom feed
* Regression: smb: chmod ignored (5.14.0-427.40.1.el9_4 vs. 5.14.0-503.15.1.el9_5)
@ 2025-01-24 23:05 Reiterer, Horst
  2025-01-24 23:16 ` Steve French
  2025-01-25 14:25 ` Paulo Alcantara
  0 siblings, 2 replies; 4+ messages in thread
From: Reiterer, Horst @ 2025-01-24 23:05 UTC (permalink / raw)
  To: linux-cifs@vger.kernel.org

Hi,

after updating from AlmaLinux 9.4 to 9.5 (https://repo.almalinux.org/vault/9.4/BaseOS/Source/Packages/kernel-5.14.0-427.40.1.el9_4.src.rpm vs. https://repo.almalinux.org/vault/9.5/BaseOS/Source/Packages/kernel-5.14.0-503.15.1.el9_5.src.rpm), chmod gets ignored by the CIFS filesystem when executed against a Windows file server unless chmod happens in another process.

Mount options as reported by mount:

  rw,relatime,context=system_u:object_r:tmp_t:s0,vers=3.1.1,cache=strict,username=<username>  
  uid=0,noforceuid,gid=0,noforcegid,addr=<addr>,file_mode=0755,dir_mode=0755,soft
  nounix,serverino,mapposix,reparse=nfs,rsize=4194304,wsize=4194304,bsize=1048576
  retrans=1,echo_interval=60,actimeo=1,closetimeo=1

Reproduction (see source below):

  ./test <path/to/mountpoint>/<non-existent-filename> all
  Unexpected mode 100555

strace:

openat(AT_FDCWD, "/mnt/test", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
close(3)                                = 0
chmod("/mnt/test", 0400) = 0
openat(AT_FDCWD, "/mnt/test", O_RDONLY) = 3
close(3)                                = 0
newfstatat(AT_FDCWD, "/mnt/test", {st_dev=makedev(0, 0x2b), st_ino=1407374884039565, st_mode=S_IFREG|0555, st_nlink=1, st_uid=0, st_gid=0, st_blksize=1048576, st_blocks=0, st_size=0, st_atime=17
37759300 /* 2025-01-24T23:55:00.242552200+0100 */, st_atime_nsec=242552200, st_mtime=1737759300 /* 2025-01-24T23:55:00.242552200+0100 */, st_mtime_nsec=242552200, st_ctime=1737759300 /* 2025-01-
24T23:55:00.243552200+0100 */, st_ctime_nsec=243552200}, 0) = 0
chmod("/mnt/test", 0600) = 0
newfstatat(AT_FDCWD, "/mnt/test", {st_dev=makedev(0, 0x2b), st_ino=1407374884039565, st_mode=S_IFREG|0555, st_nlink=1, st_uid=0, st_gid=0, st_blksize=1048576, st_blocks=0, st_size=0, st_atime=17
37759300 /* 2025-01-24T23:55:00.242552200+0100 */, st_atime_nsec=242552200, st_mtime=1737759300 /* 2025-01-24T23:55:00.242552200+0100 */, st_mtime_nsec=242552200, st_ctime=1737759300 /* 2025-01-
24T23:55:00.245552200+0100 */, st_ctime_nsec=245552200}, 0) = 0
write(2, "Unexpected mode 100555\n", 23Unexpected mode 100555
) = 23
exit_group(1)                           = ?
+++ exited with 1 +++

Workaround (executing the test in two processes):

  ./test <path/to/mountpoint>/<non-existent-filename> first
  ./test <path/to/mountpoint>/<non-existent-filename> last

strace:

openat(AT_FDCWD, "/mnt/test", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
close(3)                                = 0
chmod("/mnt/test", 0400) = 0
openat(AT_FDCWD, "/mnt/test", O_RDONLY) = 3
close(3)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++

newfstatat(AT_FDCWD, "/mnt/test", {st_dev=makedev(0, 0x2b), st_ino=1407374884039566, st_mode=S_IFREG|0555, st_nlink=1, st_uid=0, st_gid=0, st_blksize=1048576, st_blocks=0, st_size=0, st_atime=17
37759424 /* 2025-01-24T23:57:04.152930200+0100 */, st_atime_nsec=152930200, st_mtime=1737759424 /* 2025-01-24T23:57:04.152930200+0100 */, st_mtime_nsec=152930200, st_ctime=1737759424 /* 2025-01-
24T23:57:04.152930200+0100 */, st_ctime_nsec=152930200}, 0) = 0
chmod("/mnt/test", 0600) = 0
newfstatat(AT_FDCWD, "/mnt/test", {st_dev=makedev(0, 0x2b), st_ino=1407374884039566, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=1048576, st_blocks=0, st_size=0, st_atime=17
37759424 /* 2025-01-24T23:57:04.152930200+0100 */, st_atime_nsec=152930200, st_mtime=1737759424 /* 2025-01-24T23:57:04.152930200+0100 */, st_mtime_nsec=152930200, st_ctime=1737759449 /* 2025-01-
24T23:57:29.621213500+0100 */, st_ctime_nsec=621213500}, 0) = 0
openat(AT_FDCWD, "/mnt/test", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
close(3)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++

Please let me know if your can reproduce the issue using the sample.

Cheers,

Horst Reiterer

test.c:
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
  if (argc != 3) {
    fprintf(stderr, "test <path> <all|first|last>\n");
    return 2;
  }
  char *path = argv[1];
  char *mode = argv[2];
  int fd;
  if (strcmp(mode, "all") == 0 || strcmp(mode, "first") == 0) {
    if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) {
      perror("open");
      return 1;
    }
    close(fd);
    if (chmod(path, 0400) == -1) {
      perror("chmod");
      return 1;
    }
    if ((fd = open(path, O_RDONLY)) == -1) {
      perror("open");
      return 1;
    }
    close(fd);
  }
  if (strcmp(mode, "all") == 0 || strcmp(mode, "last") == 0) {
    struct stat statbuf;
    if (stat(path, &statbuf) == -1) {
      perror("stat");
      return 1;
    }
    mode_t modebefore = statbuf.st_mode;
    if (chmod(path, 0600) == -1) {
      perror("chmod");
      return 1;
    }
    if (stat(path, &statbuf) == -1) {
      perror("stat");
      return 1;
    }
    if (statbuf.st_mode == modebefore) {
      fprintf(stderr, "Unexpected mode %o\n", statbuf.st_mode);
      return 1;
    }
    if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) {
      perror("open");
      return 1;
    }
    close(fd);
  }
  return 0;
}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Regression: smb: chmod ignored (5.14.0-427.40.1.el9_4 vs. 5.14.0-503.15.1.el9_5)
  2025-01-24 23:05 Reiterer, Horst
@ 2025-01-24 23:16 ` Steve French
  2025-01-25 14:25 ` Paulo Alcantara
  1 sibling, 0 replies; 4+ messages in thread
From: Steve French @ 2025-01-24 23:16 UTC (permalink / raw)
  To: Reiterer, Horst; +Cc: linux-cifs@vger.kernel.org

Since this kernel is presumably built on Redhat's 5.14 kernel, has it
been verified whether this fails the same way on current RHEL9?


On Fri, Jan 24, 2025 at 5:05 PM Reiterer, Horst
<horst.reiterer@fabasoft.com> wrote:
>
> Hi,
>
> after updating from AlmaLinux 9.4 to 9.5 (https://repo.almalinux.org/vault/9.4/BaseOS/Source/Packages/kernel-5.14.0-427.40.1.el9_4.src.rpm vs. https://repo.almalinux.org/vault/9.5/BaseOS/Source/Packages/kernel-5.14.0-503.15.1.el9_5.src.rpm), chmod gets ignored by the CIFS filesystem when executed against a Windows file server unless chmod happens in another process.
>
> Mount options as reported by mount:
>
>   rw,relatime,context=system_u:object_r:tmp_t:s0,vers=3.1.1,cache=strict,username=<username>
>   uid=0,noforceuid,gid=0,noforcegid,addr=<addr>,file_mode=0755,dir_mode=0755,soft
>   nounix,serverino,mapposix,reparse=nfs,rsize=4194304,wsize=4194304,bsize=1048576
>   retrans=1,echo_interval=60,actimeo=1,closetimeo=1
>
> Reproduction (see source below):
>
>   ./test <path/to/mountpoint>/<non-existent-filename> all
>   Unexpected mode 100555
>
> strace:
>
> openat(AT_FDCWD, "/mnt/test", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
> close(3)                                = 0
> chmod("/mnt/test", 0400) = 0
> openat(AT_FDCWD, "/mnt/test", O_RDONLY) = 3
> close(3)                                = 0
> newfstatat(AT_FDCWD, "/mnt/test", {st_dev=makedev(0, 0x2b), st_ino=1407374884039565, st_mode=S_IFREG|0555, st_nlink=1, st_uid=0, st_gid=0, st_blksize=1048576, st_blocks=0, st_size=0, st_atime=17
> 37759300 /* 2025-01-24T23:55:00.242552200+0100 */, st_atime_nsec=242552200, st_mtime=1737759300 /* 2025-01-24T23:55:00.242552200+0100 */, st_mtime_nsec=242552200, st_ctime=1737759300 /* 2025-01-
> 24T23:55:00.243552200+0100 */, st_ctime_nsec=243552200}, 0) = 0
> chmod("/mnt/test", 0600) = 0
> newfstatat(AT_FDCWD, "/mnt/test", {st_dev=makedev(0, 0x2b), st_ino=1407374884039565, st_mode=S_IFREG|0555, st_nlink=1, st_uid=0, st_gid=0, st_blksize=1048576, st_blocks=0, st_size=0, st_atime=17
> 37759300 /* 2025-01-24T23:55:00.242552200+0100 */, st_atime_nsec=242552200, st_mtime=1737759300 /* 2025-01-24T23:55:00.242552200+0100 */, st_mtime_nsec=242552200, st_ctime=1737759300 /* 2025-01-
> 24T23:55:00.245552200+0100 */, st_ctime_nsec=245552200}, 0) = 0
> write(2, "Unexpected mode 100555\n", 23Unexpected mode 100555
> ) = 23
> exit_group(1)                           = ?
> +++ exited with 1 +++
>
> Workaround (executing the test in two processes):
>
>   ./test <path/to/mountpoint>/<non-existent-filename> first
>   ./test <path/to/mountpoint>/<non-existent-filename> last
>
> strace:
>
> openat(AT_FDCWD, "/mnt/test", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
> close(3)                                = 0
> chmod("/mnt/test", 0400) = 0
> openat(AT_FDCWD, "/mnt/test", O_RDONLY) = 3
> close(3)                                = 0
> exit_group(0)                           = ?
> +++ exited with 0 +++
>
> newfstatat(AT_FDCWD, "/mnt/test", {st_dev=makedev(0, 0x2b), st_ino=1407374884039566, st_mode=S_IFREG|0555, st_nlink=1, st_uid=0, st_gid=0, st_blksize=1048576, st_blocks=0, st_size=0, st_atime=17
> 37759424 /* 2025-01-24T23:57:04.152930200+0100 */, st_atime_nsec=152930200, st_mtime=1737759424 /* 2025-01-24T23:57:04.152930200+0100 */, st_mtime_nsec=152930200, st_ctime=1737759424 /* 2025-01-
> 24T23:57:04.152930200+0100 */, st_ctime_nsec=152930200}, 0) = 0
> chmod("/mnt/test", 0600) = 0
> newfstatat(AT_FDCWD, "/mnt/test", {st_dev=makedev(0, 0x2b), st_ino=1407374884039566, st_mode=S_IFREG|0755, st_nlink=1, st_uid=0, st_gid=0, st_blksize=1048576, st_blocks=0, st_size=0, st_atime=17
> 37759424 /* 2025-01-24T23:57:04.152930200+0100 */, st_atime_nsec=152930200, st_mtime=1737759424 /* 2025-01-24T23:57:04.152930200+0100 */, st_mtime_nsec=152930200, st_ctime=1737759449 /* 2025-01-
> 24T23:57:29.621213500+0100 */, st_ctime_nsec=621213500}, 0) = 0
> openat(AT_FDCWD, "/mnt/test", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
> close(3)                                = 0
> exit_group(0)                           = ?
> +++ exited with 0 +++
>
> Please let me know if your can reproduce the issue using the sample.
>
> Cheers,
>
> Horst Reiterer
>
> test.c:
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <sys/stat.h>
> #include <sys/types.h>
> #include <unistd.h>
>
> int main(int argc, char *argv[])
> {
>   if (argc != 3) {
>     fprintf(stderr, "test <path> <all|first|last>\n");
>     return 2;
>   }
>   char *path = argv[1];
>   char *mode = argv[2];
>   int fd;
>   if (strcmp(mode, "all") == 0 || strcmp(mode, "first") == 0) {
>     if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) {
>       perror("open");
>       return 1;
>     }
>     close(fd);
>     if (chmod(path, 0400) == -1) {
>       perror("chmod");
>       return 1;
>     }
>     if ((fd = open(path, O_RDONLY)) == -1) {
>       perror("open");
>       return 1;
>     }
>     close(fd);
>   }
>   if (strcmp(mode, "all") == 0 || strcmp(mode, "last") == 0) {
>     struct stat statbuf;
>     if (stat(path, &statbuf) == -1) {
>       perror("stat");
>       return 1;
>     }
>     mode_t modebefore = statbuf.st_mode;
>     if (chmod(path, 0600) == -1) {
>       perror("chmod");
>       return 1;
>     }
>     if (stat(path, &statbuf) == -1) {
>       perror("stat");
>       return 1;
>     }
>     if (statbuf.st_mode == modebefore) {
>       fprintf(stderr, "Unexpected mode %o\n", statbuf.st_mode);
>       return 1;
>     }
>     if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) {
>       perror("open");
>       return 1;
>     }
>     close(fd);
>   }
>   return 0;
> }
>


--
Thanks,

Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Regression: smb: chmod ignored (5.14.0-427.40.1.el9_4 vs. 5.14.0-503.15.1.el9_5)
  2025-01-24 23:05 Reiterer, Horst
  2025-01-24 23:16 ` Steve French
@ 2025-01-25 14:25 ` Paulo Alcantara
  1 sibling, 0 replies; 4+ messages in thread
From: Paulo Alcantara @ 2025-01-25 14:25 UTC (permalink / raw)
  To: Reiterer, Horst, linux-cifs@vger.kernel.org

Hi,

Thanks for the report.

"Reiterer, Horst" <horst.reiterer@fabasoft.com> writes:

> after updating from AlmaLinux 9.4 to 9.5
> (https://repo.almalinux.org/vault/9.4/BaseOS/Source/Packages/kernel-5.14.0-427.40.1.el9_4.src.rpm
> vs. https://repo.almalinux.org/vault/9.5/BaseOS/Source/Packages/kernel-5.14.0-503.15.1.el9_5.src.rpm),
> chmod gets ignored by the CIFS filesystem when executed against a
> Windows file server unless chmod happens in another process.

Yeah, I was able to reproduce it with mainline kernel as well.

Could you please file a bug [1] against File System -> CIFS component?

Thanks.

[1] https://bugzilla.kernel.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Regression: smb: chmod ignored (5.14.0-427.40.1.el9_4 vs. 5.14.0-503.15.1.el9_5)
@ 2025-01-25 22:22 Reiterer, Horst
  0 siblings, 0 replies; 4+ messages in thread
From: Reiterer, Horst @ 2025-01-25 22:22 UTC (permalink / raw)
  To: pc@manguebit.com; +Cc: linux-cifs@vger.kernel.org

Hi Paulo,

thanks for testing with mainline. Bug created:

https://bugzilla.kernel.org/show_bug.cgi?id=219724

Cheers,

Horst Reiterer

-----Ursprüngliche Nachricht-----
Von: Paulo Alcantara <pc@manguebit.com> 
Gesendet: Samstag, 25. Januar 2025 15:25
An: Reiterer, Horst <horst.reiterer@fabasoft.com>; linux-cifs@vger.kernel.org
Betreff: Re: Regression: smb: chmod ignored (5.14.0-427.40.1.el9_4 vs. 5.14.0-503.15.1.el9_5)

Hi,

Thanks for the report.

"Reiterer, Horst" <horst.reiterer@fabasoft.com> writes:

> after updating from AlmaLinux 9.4 to 9.5 
> (https://repo.almalinux.org/vault/9.4/BaseOS/Source/Packages/kernel-5.
> 14.0-427.40.1.el9_4.src.rpm vs. 
> https://repo.almalinux.org/vault/9.5/BaseOS/Source/Packages/kernel-5.1
> 4.0-503.15.1.el9_5.src.rpm), chmod gets ignored by the CIFS filesystem 
> when executed against a Windows file server unless chmod happens in 
> another process.

Yeah, I was able to reproduce it with mainline kernel as well.

Could you please file a bug [1] against File System -> CIFS component?

Thanks.

[1] https://bugzilla.kernel.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-25 22:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-25 22:22 Regression: smb: chmod ignored (5.14.0-427.40.1.el9_4 vs. 5.14.0-503.15.1.el9_5) Reiterer, Horst
  -- strict thread matches above, loose matches on Subject: below --
2025-01-24 23:05 Reiterer, Horst
2025-01-24 23:16 ` Steve French
2025-01-25 14:25 ` Paulo Alcantara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox