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.)
This commit is contained in:
Augustin Cavalier
2023-12-23 22:31:28 -05:00
parent 04f148c74a
commit 094f638456
+3 -3
View File
@@ -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;