mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user