x86: fix crash in _arch_buffer_validate

The code wasn't checking if the memory address to check
corresponded to a non-present page directory pointer
table entry.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2019-02-12 14:28:58 -08:00 committed by Anas Nashif
commit 62d866385e

View file

@ -88,6 +88,11 @@ int _arch_buffer_validate(void *addr, size_t size, int write)
end_pde_num = MMU_PDE_NUM((char *)addr + size - 1);
}
/* Ensure page directory pointer table entry is present */
if (X86_MMU_GET_PDPTE_INDEX(&USER_PDPT, pdpte)->p == 0) {
return -EPERM;
}
struct x86_mmu_pd *pd_address =
X86_MMU_GET_PD_ADDR_INDEX(&USER_PDPT, pdpte);