summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorJamie Liu <jamieliu@google.com>2018-12-18 11:51:22 -0800
committerShentubot <shentubot@google.com>2018-12-18 11:52:31 -0800
commit3b3f02627870a06de4e1fc3178d5bd23f627a97a (patch)
tree5229a7f43b7cac34772b610d835b513d3fef42a9 /pkg
parent41903586fdcc004a38ad2b0cafcac520bfa4b8f7 (diff)
Truncate ar before calling mm.breakCopyOnWriteLocked().
... as required by the latter's precondition. PiperOrigin-RevId: 226033824 Change-Id: I6bc46d0e100c61cc58cb5fc69e70c4ca905cd92d
Diffstat (limited to 'pkg')
-rw-r--r--pkg/sentry/mm/pma.go8
1 files changed, 8 insertions, 0 deletions
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)
}