summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTiwei Bie <tiwei.btw@antgroup.com>2020-07-15 22:02:26 +0800
committerTiwei Bie <tiwei.btw@antfin.com>2020-07-15 22:20:02 +0800
commit505bebae43183a68ee8873764817d282a6c49ec6 (patch)
tree4b3c634e62ed35bb4ccbe6014cd9f968f37350fa
parent1b9965e06a966977a99569484da139d64d1db95e (diff)
hostinet: fix fd leak in fdnotifier for VFS2
When we failed to create the new socket after adding the fd to fdnotifier, we should remove the fd from fdnotifier, because we are going to close the fd directly. Fixes: #3241 Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
-rw-r--r--pkg/sentry/socket/hostinet/socket_vfs2.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/pkg/sentry/socket/hostinet/socket_vfs2.go b/pkg/sentry/socket/hostinet/socket_vfs2.go
index 8f192c62f..8a1d52ebf 100644
--- a/pkg/sentry/socket/hostinet/socket_vfs2.go
+++ b/pkg/sentry/socket/hostinet/socket_vfs2.go
@@ -71,6 +71,7 @@ func newVFS2Socket(t *kernel.Task, family int, stype linux.SockType, protocol in
DenyPWrite: true,
UseDentryMetadata: true,
}); err != nil {
+ fdnotifier.RemoveFD(int32(s.fd))
return nil, syserr.FromError(err)
}
return vfsfd, nil