gvisor: validate a new map region in the mremap syscall

Right now, mremap allows to remap a memory region over MaxUserAddress,
this means that we can change the stub region.

PiperOrigin-RevId: 251266886
This commit is contained in:
Andrei Vagin
2019-06-03 10:59:46 -07:00
committed by Shentubot
parent 216da0b733
commit 8e926e3f74
+10
View File
@@ -470,6 +470,16 @@ func (mm *MemoryManager) MRemap(ctx context.Context, oldAddr usermem.Addr, oldSi
return 0, syserror.EINVAL
}
// Check that the new region is valid.
_, err := mm.findAvailableLocked(newSize, findAvailableOpts{
Addr: newAddr,
Fixed: true,
Unmap: true,
})
if err != nil {
return 0, err
}
// Unmap any mappings at the destination.
mm.unmapLocked(ctx, newAR)