From 63664eaa219e5ff754b34161839b8e82c45c95ac Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Fri, 11 Mar 2022 14:15:56 -0500 Subject: [PATCH] kernel/vm: Do not assume "no user protection" means "kernel area". It's entirely possible that we have a user area with a page that has protections of 0 (e.g. a guard page). In that case we should print the standard read/write fault message instead of "kernel" fault messages. This should not be a major behavioral change, only the syslog and tracing entries should be affected; such memory accesses should be caught by the read/write permissions checks immediately following. --- src/system/kernel/vm/vm.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index e0fc29b2ce..87b450ff7c 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -4725,7 +4725,8 @@ vm_soft_fault(VMAddressSpace* addressSpace, addr_t originalAddress, // check permissions uint32 protection = get_area_page_protection(area, address); - if (isUser && (protection & B_USER_PROTECTION) == 0) { + if (isUser && (protection & B_USER_PROTECTION) == 0 + && (area->protection & B_KERNEL_AREA) != 0) { dprintf("user access on kernel area 0x%" B_PRIx32 " at %p\n", area->id, (void*)originalAddress); TPF(PageFaultError(area->id,