From 23438b36327524ba3e71b6416d71863fb4dfa166 Mon Sep 17 00:00:00 2001 From: Jamie Liu Date: Wed, 5 Dec 2018 14:26:24 -0800 Subject: Update MM.usageAS when mremap copies or moves a mapping. PiperOrigin-RevId: 224221509 Change-Id: I7aaea74629227d682786d3e435737364921249bf --- pkg/sentry/mm/syscalls.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pkg/sentry/mm') diff --git a/pkg/sentry/mm/syscalls.go b/pkg/sentry/mm/syscalls.go index 9519c7390..1a46c2105 100644 --- a/pkg/sentry/mm/syscalls.go +++ b/pkg/sentry/mm/syscalls.go @@ -463,6 +463,7 @@ func (mm *MemoryManager) MRemap(ctx context.Context, oldAddr usermem.Addr, oldSi vma.id.IncRef() } mm.vmas.Add(newAR, vma) + mm.usageAS += uint64(newAR.Length()) return newAR.Start, nil } @@ -479,14 +480,13 @@ func (mm *MemoryManager) MRemap(ctx context.Context, oldAddr usermem.Addr, oldSi // oldAR, so calling RemoveMapping could cause us to miss an invalidation // overlapping oldAR. // - // Call vseg.Value() (rather than vseg.ValuePtr()) first to make a copy of - // the vma. + // Call vseg.Value() (rather than vseg.ValuePtr()) to make a copy of the + // vma. vseg = mm.vmas.Isolate(vseg, oldAR) vma := vseg.Value() mm.vmas.Remove(vseg) - - // Insert the new vma, transferring the reference on vma.id. mm.vmas.Add(newAR, vma) + mm.usageAS = mm.usageAS - uint64(oldAR.Length()) + uint64(newAR.Length()) // Move pmas. This is technically optional for non-private pmas, which // could just go through memmap.Mappable.Translate again, but it's required -- cgit v1.2.3