aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend/file.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2024-12-30 12:08:41 +0100
committerJakob Unterwurzacher2026-07-16 20:10:19 +0200
commit0acbbc0913a3a7069984c8e52f64e302d7f52df4 (patch)
treedc1abee5fa60d0c65393051865dc2c2724067b4c /internal/fusefrontend/file.go
parentc12811349ec04a10e4090dc1becbf92380693f62 (diff)
fusefrontend: sharedstorage: lock truncate agains concurrent access
Prevent reads and writes concurrent with the truncate operation. It's racy on tmpfs and ext4 ( https://lore.kernel.org/all/18e9fa0f-ec31-9107-459c-ae1694503f87@gmail.com/t/ ) as evident by TestOpenTruncate test failures: === RUN TestOpenTruncate cluster_test.go:209: POSIX compliance issue: non-exlusive create failed with err=file exists doRead 16384215: corrupt block #0: cipher: message authentication failed ino16384215 fh8: RMW read failed: errno=5 cluster_test.go:214: iteration 1: WriteAt: write /tmp/gocryptfs-test-parent-1026/1358464214/TestOpenTruncate.1788296708.mnt2/foo: input/output error --- FAIL: TestOpenTruncate (0.06s) FAIL exit status 1 FAIL github.com/rfjakob/gocryptfs/v2/tests/cluster 7.880s Relates-to: https://github.com/rfjakob/gocryptfs/issues/56
Diffstat (limited to 'internal/fusefrontend/file.go')
-rw-r--r--internal/fusefrontend/file.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go
index 813f992..b7ff032 100644
--- a/internal/fusefrontend/file.go
+++ b/internal/fusefrontend/file.go
@@ -258,7 +258,7 @@ func (f *File) Read(ctx context.Context, buf []byte, off int64) (resultData fuse
if !(f.rootNode.args.SharedStorage && errno == syscall.EIO) {
return nil, errno
}
- blocks := f.contentEnc.ExplodePlainRange(uint64(off), uint64(len(buf)))
+ blocks := f.rootNode.contentEnc.ExplodePlainRange(uint64(off), uint64(len(buf)))
alignedOffset, alignedLength := blocks[0].JointCiphertextRange(blocks)
if err := f.LockSharedStorage(unix.F_RDLCK, int64(alignedOffset), int64(alignedLength)); err != nil {
tlog.Warn.Printf("ino%d: FUSE Read: LockSharedStorage(F_RDLCK, %d, %d) failed: %v", f.qIno.Ino, alignedOffset, alignedLength, err)