diff options
author | Andrei Vagin <avagin@google.com> | 2019-06-24 17:44:00 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-06-24 17:45:02 -0700 |
commit | e9ea7230f7dc70d3e1bb5ae32b6927209cafb465 (patch) | |
tree | 2f8b5aacade58f48ad3f4748c5fe6875f2761f0b /pkg/sentry/fs/splice.go | |
parent | 7f5d0afe525af4728ed5ec75193e9e4560d9558c (diff) |
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
Diffstat (limited to 'pkg/sentry/fs/splice.go')
-rw-r--r-- | pkg/sentry/fs/splice.go | 2 |
1 files changed, 2 insertions, 0 deletions
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. |