diff options
author | Dean Deng <deandeng@google.com> | 2020-10-12 10:39:03 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-10-12 10:41:04 -0700 |
commit | d861cd5f14bc42b32eeac20c444a685f1d9748f7 (patch) | |
tree | 5552b9c9ef55049cd7db81caffc4b338ea256be5 /pkg/sentry/kernel | |
parent | db36d948fa63ce950d94a5e8e9ebc37956543661 (diff) |
[vfs2] Don't leak disconnected mounts.
PiperOrigin-RevId: 336694658
Diffstat (limited to 'pkg/sentry/kernel')
-rw-r--r-- | pkg/sentry/kernel/kernel.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/sentry/kernel/kernel.go b/pkg/sentry/kernel/kernel.go index d6c21adb7..16c427fc8 100644 --- a/pkg/sentry/kernel/kernel.go +++ b/pkg/sentry/kernel/kernel.go @@ -1738,3 +1738,18 @@ func (k *Kernel) ShmMount() *vfs.Mount { func (k *Kernel) SocketMount() *vfs.Mount { return k.socketMount } + +// Release releases resources owned by k. +// +// Precondition: This should only be called after the kernel is fully +// initialized, e.g. after k.Start() has been called. +func (k *Kernel) Release() { + if VFS2Enabled { + ctx := k.SupervisorContext() + k.hostMount.DecRef(ctx) + k.pipeMount.DecRef(ctx) + k.shmMount.DecRef(ctx) + k.socketMount.DecRef(ctx) + k.vfs.Release(ctx) + } +} |