From 682c0edcdcdfbf26be5d0d6efa2319f6f5259df2 Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Tue, 8 Sep 2020 14:40:57 -0700 Subject: [vfs] overlayfs: decref VD when not using it. overlay/filesystem.go:lookupLocked() did not DecRef the VD on some error paths when it would not end up saving or using the VD. PiperOrigin-RevId: 330589742 --- pkg/sentry/fsimpl/overlay/filesystem.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/sentry/fsimpl/overlay/filesystem.go b/pkg/sentry/fsimpl/overlay/filesystem.go index 87afeeaf3..b530851c5 100644 --- a/pkg/sentry/fsimpl/overlay/filesystem.go +++ b/pkg/sentry/fsimpl/overlay/filesystem.go @@ -211,6 +211,7 @@ func (fs *filesystem) lookupLocked(ctx context.Context, parent *dentry, name str lookupErr = err return false } + defer childVD.DecRef(ctx) mask := uint32(linux.STATX_TYPE) if !existsOnAnyLayer { @@ -249,6 +250,7 @@ func (fs *filesystem) lookupLocked(ctx context.Context, parent *dentry, name str } // Update child to include this layer. + childVD.IncRef() if isUpper { child.upperVD = childVD child.copiedUp = 1 -- cgit v1.2.3