From 412bcb11fdfc8ffcdabf014e5a019c96c3c6d918 Mon Sep 17 00:00:00 2001 From: Trung Nguyen Date: Thu, 11 May 2023 20:40:12 +1000 Subject: [PATCH] kernel/vm: Fix area_for with PROT_NONE address Do not assume "no user protection" means "kernel area". This allows calls to `area_for` for addresses with protection 0 to work properly. Change-Id: I54cbcc154d10b63359a2e1233f0c0f45d0d8e21e Reviewed-on: https://review.haiku-os.org/c/haiku/+/6388 Reviewed-by: waddlesplash --- 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 29280d7d51..4ba4e85edf 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -3810,7 +3810,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) + if (!kernel && (area->protection & (B_READ_AREA | B_WRITE_AREA)) == 0 + && (area->protection & B_KERNEL_AREA) != 0) return B_ERROR; return area->id;