diff options
author | Fabricio Voznika <fvoznika@google.com> | 2020-08-12 11:12:12 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-08-12 11:14:17 -0700 |
commit | 776c5f633edc993652bc8e95418729e0420c6324 (patch) | |
tree | 3a8002683078ff5319bd5d07fac8c00b4712aabd /pkg | |
parent | c92242c89a47e75cc8a0aa40bcb2b105ce795b90 (diff) |
Fix race in vfs.FileDescription.statusFlag
PiperOrigin-RevId: 326270643
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/sentry/vfs/file_description.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/pkg/sentry/vfs/file_description.go b/pkg/sentry/vfs/file_description.go index d3c1197e3..dcafffe57 100644 --- a/pkg/sentry/vfs/file_description.go +++ b/pkg/sentry/vfs/file_description.go @@ -289,7 +289,7 @@ func (fd *FileDescription) SetStatusFlags(ctx context.Context, creds *auth.Crede if flags&linux.O_DIRECT != 0 && !fd.opts.AllowDirectIO { return syserror.EINVAL } - // TODO(jamieliu): FileDescriptionImpl.SetOAsync()? + // TODO(gvisor.dev/issue/1035): FileDescriptionImpl.SetOAsync()? const settableFlags = linux.O_APPEND | linux.O_ASYNC | linux.O_DIRECT | linux.O_NOATIME | linux.O_NONBLOCK fd.flagsMu.Lock() if fd.asyncHandler != nil { @@ -301,7 +301,7 @@ func (fd *FileDescription) SetStatusFlags(ctx context.Context, creds *auth.Crede fd.asyncHandler.Unregister(fd) } } - fd.statusFlags = (oldFlags &^ settableFlags) | (flags & settableFlags) + atomic.StoreUint32(&fd.statusFlags, (oldFlags&^settableFlags)|(flags&settableFlags)) fd.flagsMu.Unlock() return nil } |