From 3b3f02627870a06de4e1fc3178d5bd23f627a97a Mon Sep 17 00:00:00 2001 From: Jamie Liu Date: Tue, 18 Dec 2018 11:51:22 -0800 Subject: Truncate ar before calling mm.breakCopyOnWriteLocked(). ... as required by the latter's precondition. PiperOrigin-RevId: 226033824 Change-Id: I6bc46d0e100c61cc58cb5fc69e70c4ca905cd92d --- pkg/sentry/mm/pma.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/sentry/mm/pma.go b/pkg/sentry/mm/pma.go index 5690fe6b4..63c50f719 100644 --- a/pkg/sentry/mm/pma.go +++ b/pkg/sentry/mm/pma.go @@ -138,6 +138,10 @@ func (mm *MemoryManager) getPMAsLocked(ctx context.Context, vseg vmaIterator, ar var cowerr error if opts.breakCOW { + if pend.Start() < ar.End { + // Adjust ar to reflect missing pmas. + ar.End = pend.Start() + } var invalidated bool pend, invalidated, cowerr = mm.breakCopyOnWriteLocked(pstart, ar) if pend.Start() <= ar.Start { @@ -189,6 +193,10 @@ func (mm *MemoryManager) getVecPMAsLocked(ctx context.Context, ars usermem.AddrR if !pstart.Ok() { pstart = mm.findOrSeekPrevUpperBoundPMA(ar.Start, pend) } + if pend.Start() < ar.End { + // Adjust ar to reflect missing pmas. + ar.End = pend.Start() + } pend, _, cowerr = mm.breakCopyOnWriteLocked(pstart, ar) } -- cgit v1.2.3