From 16882484f96f9d75348904bd5a4e2a53acb67378 Mon Sep 17 00:00:00 2001 From: Jamie Liu Date: Mon, 25 Jun 2018 16:49:47 -0700 Subject: Check for empty applicationAddrRange in MM.DecUsers. PiperOrigin-RevId: 202043776 Change-Id: I4373abbcf735dc1cf4bebbbbb0c7124df36e9e78 --- pkg/sentry/mm/lifecycle.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/sentry/mm/lifecycle.go b/pkg/sentry/mm/lifecycle.go index de7f29b04..a4b5cb443 100644 --- a/pkg/sentry/mm/lifecycle.go +++ b/pkg/sentry/mm/lifecycle.go @@ -214,5 +214,9 @@ func (mm *MemoryManager) DecUsers(ctx context.Context) { mm.mappingMu.Lock() defer mm.mappingMu.Unlock() - mm.unmapLocked(ctx, mm.applicationAddrRange()) + // If mm is being dropped before mm.SetMmapLayout was called, + // mm.applicationAddrRange() will be empty. + if ar := mm.applicationAddrRange(); ar.Length() != 0 { + mm.unmapLocked(ctx, ar) + } } -- cgit v1.2.3