From b5919d3065a28c1fd6f27612bafd28f06bf3f0d0 Mon Sep 17 00:00:00 2001 From: Dean Deng Date: Thu, 15 Apr 2021 16:29:15 -0700 Subject: Generate notification when closing host fd. Thanks ianlewis@ for discovering the bug/fix! PiperOrigin-RevId: 368740744 --- pkg/sentry/fsimpl/host/host.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'pkg/sentry') diff --git a/pkg/sentry/fsimpl/host/host.go b/pkg/sentry/fsimpl/host/host.go index 3b90375b6..a81f550b1 100644 --- a/pkg/sentry/fsimpl/host/host.go +++ b/pkg/sentry/fsimpl/host/host.go @@ -460,6 +460,9 @@ func (i *inode) DecRef(ctx context.Context) { if err := unix.Close(i.hostFD); err != nil { log.Warningf("failed to close host fd %d: %v", i.hostFD, err) } + // We can't rely on fdnotifier when closing the fd, because the event may race + // with fdnotifier.RemoveFD. Instead, notify the queue explicitly. + i.queue.Notify(waiter.EventHUp | waiter.ReadableEvents | waiter.WritableEvents) }) } -- cgit v1.2.3