qubes-linux-utils/qrexec-lib
Rusty Bird f3ffcfe9ba
qfile-unpacker: syncfs() to avoid qvm-move-to-vm data loss
Commit https://github.com/QubesOS/qubes-linux-utils/commit/c1d42f1 --
"qfile-unpacker: do not call fdatasync() at each file" fixing
QubesOS/qubes-issues#1257 -- increased the chance of data loss with
qvm-move-to-vm: Say it nominally succeeds, and *deletes* the files from
the source VM. Soon after, the destination VM or the system could crash,
or an external drive hosting ~/QubesIncoming/srcVM could get unplugged
by accident, all before the data had really been persisted to disk.

But reverting the commit (ignoring the performance issue) wouldn't
completely solve this:

  "Calling fsync() does not necessarily ensure that the entry in the
   directory containing the file has also reached disk. For that an
   explicit fsync() on a file descriptor for the directory is also
   needed."  - fsync(2)

It gets even worse for "slow symlinks" (whose target is too long to be
stored directly in the inode metadata), apparently they can't be synced
at all individually.

So instead, just call syncfs() once after everything has been unpacked:

  + Should prevent all data loss (if fs and disk are well behaved)
  + Allows caching and reordering -> no slowdown with many small files
  - Blocks until any unrelated writes on the filesystem finish :\

(cherry picked from commit 4f59b3df6f)
2015-12-11 21:08:02 +01:00
..
buffer.c linux-utils: misc const/prototype fixups 2014-01-06 14:40:57 +01:00
copy-file.c Add a few consts where appropriate 2014-02-16 11:08:22 +01:00
crc32.c Qrexec common code, qubes.Filecopy common code, udev scripts 2013-03-20 06:27:32 +01:00
crc32.h Qrexec common code, qubes.Filecopy common code, udev scripts 2013-03-20 06:27:32 +01:00
exec.c qrexec: create stdin/out/err as sockets instead of pipes 2015-02-16 23:11:37 +01:00
ioall.c ioall: do not reset file flags when they're already as requested 2014-01-06 14:40:57 +01:00
ioall.h linux-utils: misc const/prototype fixups 2014-01-06 14:40:57 +01:00
libqrexec-utils.h libqrexec-utils: bring back buffered write helpers 2015-10-30 15:33:12 +01:00
libqubes-rpc-filecopy.h filecopy: create new file unaccessible to the user until fully written 2015-01-30 00:55:46 +01:00
Makefile libqrexec-utils: bump SO version because of ABI change 2015-10-30 15:33:16 +01:00
qrexec.h qrexec: update protocol 2014-11-19 15:10:59 +01:00
txrx-vchan.c Fix compile warnings 2014-11-19 15:10:59 +01:00
unix-server.c unix-server: do not check for unlink() error when creating socket 2014-01-07 00:27:57 +01:00
unpack.c qfile-unpacker: syncfs() to avoid qvm-move-to-vm data loss 2015-12-11 21:08:02 +01:00
write-stdin.c libqrexec-utils: bring back buffered write helpers 2015-10-30 15:33:12 +01:00