Skip to content

Commit

Permalink
Hold d.parent.mu when reading d.name
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 203041657
Change-Id: I120783d91712818e600505454c9276f8d9877f37
  • Loading branch information
prattmic authored and shentubot committed Jul 3, 2018
1 parent 126296c commit 2821dfe
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/sentry/fs/dirent.go
Expand Up @@ -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)

Expand Down

0 comments on commit 2821dfe

Please sign in to comment.