riscv: check type of cap before checking if mapped

In decodeRISCVMMUInvocation, in the asid_pool_cap case, the first extra
cap is supplied by the user. Before asking whether the page table cap is
mapped, we should check it is a page table cap.

Signed-off-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
This commit is contained in:
Rafal Kolanski 2020-04-22 04:22:33 +10:00
parent 869dc4a4c0
commit 7ad699e4fb

View file

@ -1002,7 +1002,9 @@ exception_t decodeRISCVMMUInvocation(word_t label, word_t length, cptr_t cptr,
vspaceCapSlot = extraCaps.excaprefs[0];
vspaceCap = vspaceCapSlot->cap;
if (cap_page_table_cap_get_capPTIsMapped(vspaceCap)) {
if (unlikely(
cap_get_capType(vspaceCap) != cap_page_table_cap ||
cap_page_table_cap_get_capPTIsMapped(vspaceCap))) {
userError("RISCVASIDPool: Invalid vspace root.");
current_syscall_error.type = seL4_InvalidCapability;
current_syscall_error.invalidCapNumber = 1;