From e9ea7230f7dc70d3e1bb5ae32b6927209cafb465 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Mon, 24 Jun 2019 17:44:00 -0700 Subject: fs: synchronize concurrent writes into files with O_APPEND For files with O_APPEND, a file write operation gets a file size and uses it as offset to call an inode write operation. This means that all other operations which can change a file size should be blocked while the write operation doesn't complete. PiperOrigin-RevId: 254873771 --- pkg/sentry/fs/splice.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pkg/sentry/fs/splice.go') diff --git a/pkg/sentry/fs/splice.go b/pkg/sentry/fs/splice.go index 978dc679b..eed1c2854 100644 --- a/pkg/sentry/fs/splice.go +++ b/pkg/sentry/fs/splice.go @@ -88,6 +88,8 @@ func Splice(ctx context.Context, dst *File, src *File, opts SpliceOpts) (int64, // Check append-only mode and the limit. if !dstPipe { + unlock := dst.Dirent.Inode.lockAppendMu(dst.Flags().Append) + defer unlock() if dst.Flags().Append { if opts.DstOffset { // We need to acquire the lock. -- cgit v1.2.3