Regression: smb: chmod ignored (5.14.0-427.40.1.el9_4 vs. 5.14.0-503.15.1.el9_5)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
}





[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux