From 7483666eca67bf7d7ee814a4c8667af575f15bda Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Tue, 25 Aug 2020 14:58:28 -0700 Subject: overlay: clonePrivateMount must pass a Dentry reference to MakeVirtualDentry. PiperOrigin-RevId: 328410065 --- pkg/sentry/fsimpl/overlay/overlay.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pkg/sentry') diff --git a/pkg/sentry/fsimpl/overlay/overlay.go b/pkg/sentry/fsimpl/overlay/overlay.go index 4b3dfbc01..00562667f 100644 --- a/pkg/sentry/fsimpl/overlay/overlay.go +++ b/pkg/sentry/fsimpl/overlay/overlay.go @@ -315,7 +315,11 @@ func clonePrivateMount(vfsObj *vfs.VirtualFilesystem, vd vfs.VirtualDentry, forc if err != nil { return vfs.VirtualDentry{}, err } - return vfs.MakeVirtualDentry(newmnt, vd.Dentry()), nil + // Take a reference on the dentry which will be owned by the returned + // VirtualDentry. + d := vd.Dentry() + d.IncRef() + return vfs.MakeVirtualDentry(newmnt, d), nil } // Release implements vfs.FilesystemImpl.Release. -- cgit v1.2.3