]> 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)
commit8966343b11528f158f35e153726066be35745552
treec9e079d1a9a3e9fe320fbe0298aa3cd6c975510d
parenteb24f23fe9f97799743fde5b972bda9c422467ea
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: 72512e623802 ("fuse: Turn writeback cache on")
Cc: <stable@vger.kernel.org> # v3.15+
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/dir.c