summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/ramfs/dir.go
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2019-01-28 13:25:27 -0800
committerShentubot <shentubot@google.com>2019-01-28 13:26:28 -0800
commit09cf3b40a8994a3f52dfe2a85e5198c5986b8264 (patch)
treec4902a5e63f756236c837c6e006084fe5819afb8 /pkg/sentry/fs/ramfs/dir.go
parent9114471a5a5428bd8858d291811249314473d12d (diff)
Fix data race in InodeSimpleAttributes.Unstable.
We were modifying InodeSimpleAttributes.Unstable.AccessTime without holding the necessary lock. Luckily for us, InodeSimpleAttributes already has a NotifyAccess method that will do the update while holding the lock. In addition, we were holding dfo.dir.mu.Lock while setting AccessTime, which is unnecessary, so that lock has been removed. PiperOrigin-RevId: 231278447 Change-Id: I81ed6d3dbc0b18e3f90c1df5e5a9c06132761769
Diffstat (limited to 'pkg/sentry/fs/ramfs/dir.go')
-rw-r--r--pkg/sentry/fs/ramfs/dir.go5
1 files changed, 1 insertions, 4 deletions
diff --git a/pkg/sentry/fs/ramfs/dir.go b/pkg/sentry/fs/ramfs/dir.go
index 729f37694..696825eb5 100644
--- a/pkg/sentry/fs/ramfs/dir.go
+++ b/pkg/sentry/fs/ramfs/dir.go
@@ -22,7 +22,6 @@ import (
"gvisor.googlesource.com/gvisor/pkg/sentry/context"
"gvisor.googlesource.com/gvisor/pkg/sentry/fs"
"gvisor.googlesource.com/gvisor/pkg/sentry/fs/fsutil"
- ktime "gvisor.googlesource.com/gvisor/pkg/sentry/kernel/time"
"gvisor.googlesource.com/gvisor/pkg/sentry/socket/unix/transport"
"gvisor.googlesource.com/gvisor/pkg/syserror"
)
@@ -415,9 +414,7 @@ func (dfo *dirFileOperations) Readdir(ctx context.Context, file *fs.File, serial
Serializer: serializer,
DirCursor: &dfo.dirCursor,
}
- dfo.dir.mu.Lock()
- dfo.dir.InodeSimpleAttributes.Unstable.AccessTime = ktime.NowFromContext(ctx)
- dfo.dir.mu.Unlock()
+ dfo.dir.InodeSimpleAttributes.NotifyAccess(ctx)
return fs.DirentReaddir(ctx, file.Dirent, dfo, root, dirCtx, file.Offset())
}