From 8f76d1ea0a63f546ad09fa70be1ed7b6a7d29fe6 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Fri, 2 Jun 2023 14:24:44 +0200 Subject: fusefrontend: sharedstorage: use byte-range lock on file header creation Multiple host writing to the same empty file at the same time could have overwritten each other's newly created file header, leading to data corruption. Fix the race by placing a byte-range lock on the file when creating the file header. --- internal/syscallcompat/sys_darwin.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'internal/syscallcompat/sys_darwin.go') diff --git a/internal/syscallcompat/sys_darwin.go b/internal/syscallcompat/sys_darwin.go index 06f09f0..b13b6a5 100644 --- a/internal/syscallcompat/sys_darwin.go +++ b/internal/syscallcompat/sys_darwin.go @@ -27,6 +27,10 @@ const ( RENAME_EXCHANGE = 2 RENAME_WHITEOUT = 4 + // F_OFD_SETLKW only exists on Linux. On Darwin, fall back to F_SETLKW as a + // flawed replacement. + F_OFD_SETLKW = unix.F_SETLKW + // KAUTH_UID_NONE and KAUTH_GID_NONE are special values to // revert permissions to the process credentials. KAUTH_UID_NONE = ^uint32(0) - 100 -- cgit v1.2.3