summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2018-07-02 17:38:01 -0700
committerShentubot <shentubot@google.com>2018-07-02 17:39:10 -0700
commit2821dfe6ce95ad32bb0084cb3b2335bf7b31de7a (patch)
treed238b9f3fe1504a5b71a3817cae54d56cf66bacc /pkg/sentry/fs
parent126296ce2adce615005ae16edb8b80e3bfae56cd (diff)
Hold d.parent.mu when reading d.name
PiperOrigin-RevId: 203041657 Change-Id: I120783d91712818e600505454c9276f8d9877f37
Diffstat (limited to 'pkg/sentry/fs')
-rw-r--r--pkg/sentry/fs/dirent.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/pkg/sentry/fs/dirent.go b/pkg/sentry/fs/dirent.go
index 739ae1d2d..410f93b13 100644
--- a/pkg/sentry/fs/dirent.go
+++ b/pkg/sentry/fs/dirent.go
@@ -1342,7 +1342,15 @@ func (d *Dirent) InotifyEvent(events, cookie uint32) {
// The ordering below is important, Linux always notifies the parent first.
if d.parent != nil {
- d.parent.Inode.Watches.Notify(d.name, events, cookie)
+ // name is immediately stale w.r.t. renames (renameMu doesn't
+ // protect against renames in the same directory). Holding
+ // d.parent.mu around Notify() wouldn't matter since Notify
+ // doesn't provide a synchronous mechanism for reading the name
+ // anyway.
+ d.parent.mu.Lock()
+ name := d.name
+ d.parent.mu.Unlock()
+ d.parent.Inode.Watches.Notify(name, events, cookie)
}
d.Inode.Watches.Notify("", events, cookie)