summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
authorJamie Liu <jamieliu@google.com>2018-12-18 13:49:22 -0800
committerShentubot <shentubot@google.com>2018-12-18 13:50:33 -0800
commit898838e34d1b0c76405f3e7f7f5fa7f1a444da0e (patch)
tree1df651c9cd69b5bc68cc750f2366cfd70eaee0d1 /pkg/sentry
parent0759f3afee5b02d1f43b54f90111086cdc78338e (diff)
Fix mremap expansion with mm.checkInvariants = true.
Also remove useless RSS changes in mm.movePMAsLocked(). PiperOrigin-RevId: 226052996 Change-Id: If59fd259b93238fb2f15c1c8ebfeda14cb590a87
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/mm/pma.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/pkg/sentry/mm/pma.go b/pkg/sentry/mm/pma.go
index 63c50f719..d102035d8 100644
--- a/pkg/sentry/mm/pma.go
+++ b/pkg/sentry/mm/pma.go
@@ -679,7 +679,7 @@ func Unpin(prs []PinnedRange) {
// movePMAsLocked moves all pmas in oldAR to newAR.
//
// Preconditions: mm.activeMu must be locked for writing. oldAR.Length() != 0.
-// oldAR.Length() == newAR.Length(). !oldAR.Overlaps(newAR).
+// oldAR.Length() <= newAR.Length(). !oldAR.Overlaps(newAR).
// mm.pmas.IsEmptyRange(newAR). oldAR and newAR must be page-aligned.
func (mm *MemoryManager) movePMAsLocked(oldAR, newAR usermem.AddrRange) {
if checkInvariants {
@@ -689,8 +689,8 @@ func (mm *MemoryManager) movePMAsLocked(oldAR, newAR usermem.AddrRange) {
if !newAR.WellFormed() || newAR.Length() <= 0 || !newAR.IsPageAligned() {
panic(fmt.Sprintf("invalid newAR: %v", newAR))
}
- if oldAR.Length() != newAR.Length() {
- panic(fmt.Sprintf("old and new address ranges have different lengths: %v, %v", oldAR, newAR))
+ if oldAR.Length() > newAR.Length() {
+ panic(fmt.Sprintf("old address range %v may contain pmas that will not fit in new address range %v", oldAR, newAR))
}
if oldAR.Overlaps(newAR) {
panic(fmt.Sprintf("old and new address ranges overlap: %v, %v", oldAR, newAR))
@@ -710,8 +710,9 @@ func (mm *MemoryManager) movePMAsLocked(oldAR, newAR usermem.AddrRange) {
oldAR: pseg.Range(),
pma: pseg.Value(),
})
- mm.removeRSSLocked(pseg.Range())
pseg = mm.pmas.Remove(pseg).NextSegment()
+ // No RSS change is needed since we're re-inserting the same pmas
+ // below.
}
off := newAR.Start - oldAR.Start
@@ -719,7 +720,6 @@ func (mm *MemoryManager) movePMAsLocked(oldAR, newAR usermem.AddrRange) {
for i := range movedPMAs {
mpma := &movedPMAs[i]
pmaNewAR := usermem.AddrRange{mpma.oldAR.Start + off, mpma.oldAR.End + off}
- mm.addRSSLocked(pmaNewAR)
pgap = mm.pmas.Insert(pgap, pmaNewAR, mpma.pma).NextGap()
}