mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-10-05 16:46:35 -05:00
Volumes encrypted in user space are mounted through a loop device on the FUSE volume image, and their writes end in buffered pwrite() calls to the backing file or device. The FUSE service had no fsync callback, so libfuse answered the fsync requests that the loop device issues for block-layer flushes with ENOSYS, which Linux FUSE reports as success. Synced data could therefore remain dirty in the host cache, and writeback errors were not reported. Register an fsync callback that syncs the backing storage for the volume image and returns its errors through the existing mapping. Never return ENOSYS, which would make Linux FUSE stop forwarding fsync for the whole mount: report a backing ENOSYS as EIO, as the loop driver does, and return success for the other files. Other Unix platforms are outside this change. Add regression coverage on device- and file-backed volumes: fsync must flush the backing device, a backing failure must be reported as EIO, and synced data must survive a simulated power cut. Without this change, the synced data is lost. Validated with FUSE2 and FUSE3 builds.