From c125a3250887bdf707baa93dc86e79cf238b9c48 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 13 Jan 2025 14:52:38 -0500 Subject: [PATCH] kernel/vm: Adjust kernel permissions check in vm_area_for. Areas in the kernel address space generally won't have B_KERNEL_AREA. Instead we should check if the area in question has user permissions at all. If it doesn't, then return an error. If the address space isn't the kernel one, then we don't bother with this check, as all areas in the user address space should be returned even if they don't have permissions or are a "kernel" area. --- src/system/kernel/vm/vm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index d5a3cee0dd..f56eefda37 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -3463,8 +3463,8 @@ vm_area_for(addr_t address, bool kernel) VMArea* area = locker.AddressSpace()->LookupArea(address); if (area != NULL) { - if (!kernel && (area->protection & (B_READ_AREA | B_WRITE_AREA)) == 0 - && (area->protection & B_KERNEL_AREA) != 0) + if (!kernel && team == VMAddressSpace::KernelID() + && (area->protection & (B_READ_AREA | B_WRITE_AREA | B_CLONEABLE_AREA)) == 0) return B_ERROR; return area->id;