summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/host
diff options
context:
space:
mode:
authorTiwei Bie <tiwei.btw@antgroup.com>2020-09-01 16:01:22 +0800
committerTiwei Bie <tiwei.btw@antgroup.com>2020-09-01 16:35:03 +0800
commitd5f20209cc34a5357486a2f495bfe30b5d6e2056 (patch)
tree46e4c7e297500674d92b2ea539dd106a6f1385f5 /pkg/sentry/fsimpl/host
parent67484384935fa814e978f08dfa0f0bdbddbbd371 (diff)
fsimpl/host: fix the order of removing FD notifier
FD notifier should be removed before we close the FD, otherwise there will be race condition that another FD which has the same value is opened and added before the existing FD notifier is removed. Fixes: #3823 Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
Diffstat (limited to 'pkg/sentry/fsimpl/host')
-rw-r--r--pkg/sentry/fsimpl/host/socket.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/pkg/sentry/fsimpl/host/socket.go b/pkg/sentry/fsimpl/host/socket.go
index 131145b85..8a447e29f 100644
--- a/pkg/sentry/fsimpl/host/socket.go
+++ b/pkg/sentry/fsimpl/host/socket.go
@@ -348,10 +348,10 @@ func (e *SCMConnectedEndpoint) Init() error {
func (e *SCMConnectedEndpoint) Release(ctx context.Context) {
e.DecRef(func() {
e.mu.Lock()
+ fdnotifier.RemoveFD(int32(e.fd))
if err := syscall.Close(e.fd); err != nil {
log.Warningf("Failed to close host fd %d: %v", err)
}
- fdnotifier.RemoveFD(int32(e.fd))
e.destroyLocked()
e.mu.Unlock()
})