Skip to content

Commit d186f13

Browse files
prattmicshentubot
authored andcommitted
Hold d.parent.mu when reading d.name
PiperOrigin-RevId: 203041657
1 parent bb95603 commit d186f13

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/sentry/fs/dirent.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,15 @@ func (d *Dirent) InotifyEvent(events, cookie uint32) {
13421342

13431343
// The ordering below is important, Linux always notifies the parent first.
13441344
if d.parent != nil {
1345-
d.parent.Inode.Watches.Notify(d.name, events, cookie)
1345+
// name is immediately stale w.r.t. renames (renameMu doesn't
1346+
// protect against renames in the same directory). Holding
1347+
// d.parent.mu around Notify() wouldn't matter since Notify
1348+
// doesn't provide a synchronous mechanism for reading the name
1349+
// anyway.
1350+
d.parent.mu.Lock()
1351+
name := d.name
1352+
d.parent.mu.Unlock()
1353+
d.parent.Inode.Watches.Notify(name, events, cookie)
13461354
}
13471355
d.Inode.Watches.Notify("", events, cookie)
13481356

0 commit comments

Comments
 (0)