diff options
author | Fabricio Voznika <fvoznika@google.com> | 2018-12-21 11:52:39 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-12-21 11:54:02 -0800 |
commit | 1679ef31ef15344eba218a5251fa1fb1438b4cb7 (patch) | |
tree | 8ca6bb1f5a074dfc21925f31f5f461fc93b140c0 /pkg/sentry/fs/inotify_watch.go | |
parent | 5c7f70a07d8f4b08db3446e0cf75ad43bb2c1953 (diff) |
inotify notifies watchers when control events bit are set
The code that matches the event being published with events watchers
was wronly matching all watchers in case any of the control event bits
were set.
Issue #121
PiperOrigin-RevId: 226521230
Change-Id: Ie2c42bc4366faaf59fbf80a74e9297499bd93f9e
Diffstat (limited to 'pkg/sentry/fs/inotify_watch.go')
-rw-r--r-- | pkg/sentry/fs/inotify_watch.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/pkg/sentry/fs/inotify_watch.go b/pkg/sentry/fs/inotify_watch.go index b83544c9f..d33e7e498 100644 --- a/pkg/sentry/fs/inotify_watch.go +++ b/pkg/sentry/fs/inotify_watch.go @@ -76,15 +76,17 @@ func isRenameEvent(eventMask uint32) bool { // Notify queues a new event on this watch. func (w *Watch) Notify(name string, events uint32, cookie uint32) { - unmaskableBits := ^uint32(0) &^ linux.IN_ALL_EVENTS - effectiveMask := unmaskableBits | atomic.LoadUint32(&w.mask) - matchedEvents := effectiveMask & events - - if matchedEvents == 0 { + mask := atomic.LoadUint32(&w.mask) + if mask&events == 0 { // We weren't watching for this event. return } + // Event mask should include bits matched from the watch plus all control + // event bits. + unmaskableBits := ^uint32(0) &^ linux.IN_ALL_EVENTS + effectiveMask := unmaskableBits | mask + matchedEvents := effectiveMask & events w.owner.queueEvent(newEvent(w.wd, name, matchedEvents, cookie)) } |