]> git.baikalelectronics.ru Git - kernel.git/commit
fuse: flush dirty data/metadata before non-truncate setattr
authorMiklos Szeredi <mszeredi@redhat.com>
Wed, 23 Oct 2019 12:26:37 +0000 (14:26 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Wed, 23 Oct 2019 12:26:37 +0000 (14:26 +0200)
commitd78b56d3e993831aa49c77c9b5337143d400e52d
treec9e079d1a9a3e9fe320fbe0298aa3cd6c975510d
parenta655082e46f800475644e583a327aaf47edcd89d
fuse: flush dirty data/metadata before non-truncate setattr

If writeback cache is enabled, then writes might get reordered with
chmod/chown/utimes.  The problem with this is that performing the write in
the fuse daemon might itself change some of these attributes.  In such case
the following sequence of operations will result in file ending up with the
wrong mode, for example:

  int fd = open ("suid", O_WRONLY|O_CREAT|O_EXCL);
  write (fd, "1", 1);
  fchown (fd, 0, 0);
  fchmod (fd, 04755);
  close (fd);

This patch fixes this by flushing pending writes before performing
chown/chmod/utimes.

Reported-by: Giuseppe Scrivano <gscrivan@redhat.com>
Tested-by: Giuseppe Scrivano <gscrivan@redhat.com>
Fixes: c247a6c81fb5 ("fuse: Turn writeback cache on")
Cc: <stable@vger.kernel.org> # v3.15+
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/dir.c