[kernel][vm] More rigorous VDSO unmap range check
This modifies the range check in Unmap to account for the range
partially overlapping with the vdso mapping. Presently there is no way
to actually trigger this since
* `allow_partial_vmar` must be true for the previous check to not be
sufficient.
* `allow_partial_vmar` is only true when called from
`UnmapAllowPartial`, which is only called from from the hypervisor
code against a guest physical address space, and such an address
space does not have a vdso.
No tests are added for this change since
* Userspace cannot trigger this as there is no way for it to cause
`UnmapAllowPartial` to get called on an address space with a vdso.
* Kernel cannot presently clone the VDso VMO itself to create a fake
address space for testing.
ZX-4394 #done
Change-Id: I38128b9ebd3046b6c98f33c88f7608cf7e348219
diff --git a/zircon/kernel/vm/vm_address_region.cc b/zircon/kernel/vm/vm_address_region.cc
index 7ba2032..a264e37 100644
--- a/zircon/kernel/vm/vm_address_region.cc
+++ b/zircon/kernel/vm/vm_address_region.cc
@@ -669,8 +669,8 @@
// Any unmap spanning the vDSO code mapping is verboten.
if (aspace_->vdso_code_mapping_ &&
- aspace_->vdso_code_mapping_->base() >= base &&
- aspace_->vdso_code_mapping_->base() - base < size) {
+ Intersects(aspace_->vdso_code_mapping_->base(), aspace_->vdso_code_mapping_->size(), base,
+ size)) {
return ZX_ERR_ACCESS_DENIED;
}