From 094f6384569a2a6ace43a4970c8878620ec481dd Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 23 Dec 2023 22:31:28 -0500 Subject: [PATCH] kernel/vm: Perform area ownership check before protection check. This way we do not "leak" area protection status (not really a significant concern at the moment, but might as well while I was looking at this.) --- src/system/kernel/vm/vm.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index 49e752b678..20aa0a53fc 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -2918,9 +2918,6 @@ vm_set_area_protection(team_id team, area_id areaID, uint32 newProtection, return B_NOT_ALLOWED; } - if (area->protection == newProtection) - return B_OK; - if (team != VMAddressSpace::KernelID() && area->address_space->ID() != team) { // unless you're the kernel, you are only allowed to set @@ -2928,6 +2925,9 @@ vm_set_area_protection(team_id team, area_id areaID, uint32 newProtection, return B_NOT_ALLOWED; } + if (area->protection == newProtection) + return B_OK; + isWritable = (area->protection & (B_WRITE_AREA | B_KERNEL_WRITE_AREA)) != 0;