From 3946075403a93907138f13e61bdba075aeabfecf Mon Sep 17 00:00:00 2001 From: Dean Deng Date: Tue, 26 Jan 2021 00:00:52 -0800 Subject: Do not generate extraneous IN_CLOSE inotify events. IN_CLOSE should only be generated when a file description loses its last reference; not when a file descriptor is closed. See fs/file_table.c:__fput. Updates #5348. PiperOrigin-RevId: 353810697 --- pkg/sentry/vfs/file_description.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'pkg/sentry/vfs') diff --git a/pkg/sentry/vfs/file_description.go b/pkg/sentry/vfs/file_description.go index eb6c2e36b..326e35688 100644 --- a/pkg/sentry/vfs/file_description.go +++ b/pkg/sentry/vfs/file_description.go @@ -161,6 +161,13 @@ func (fd *FileDescription) Init(impl FileDescriptionImpl, flags uint32, mnt *Mou // DecRef decrements fd's reference count. func (fd *FileDescription) DecRef(ctx context.Context) { fd.FileDescriptionRefs.DecRef(func() { + // Generate inotify events. + ev := uint32(linux.IN_CLOSE_NOWRITE) + if fd.IsWritable() { + ev = linux.IN_CLOSE_WRITE + } + fd.Dentry().InotifyWithParent(ctx, ev, 0, PathEvent) + // Unregister fd from all epoll instances. fd.epollMu.Lock() epolls := fd.epolls -- cgit v1.2.3