kernel/vm: Cleanups and minor fixes to get_area_page_protection.
* We should not assume all non-kernel areas have KERNEL_READ_AREA permission, but follow the other permission flags directly. This way the kernel will be blocked from accessing guard pages, too. * Compute kernelProtection only once, and either return it directly or return it OR'd with the user protections. Change-Id: Id6daa1cd15eb3102e23f95c08672ad97344e0722 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5096 Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com> Reviewed-by: waddlesplash <waddlesplash@gmail.com> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
parent
4c51faeb59
commit
a09dd6bb6c
@ -505,19 +505,17 @@ get_area_page_protection(VMArea* area, addr_t pageAddress)
|
||||
else
|
||||
protection >>= 4;
|
||||
|
||||
// If this is a kernel area we translate the user flags to kernel flags.
|
||||
if (area->address_space == VMAddressSpace::Kernel()) {
|
||||
uint32 kernelProtection = 0;
|
||||
if ((protection & B_READ_AREA) != 0)
|
||||
kernelProtection |= B_KERNEL_READ_AREA;
|
||||
if ((protection & B_WRITE_AREA) != 0)
|
||||
kernelProtection |= B_KERNEL_WRITE_AREA;
|
||||
uint32 kernelProtection = 0;
|
||||
if ((protection & B_READ_AREA) != 0)
|
||||
kernelProtection |= B_KERNEL_READ_AREA;
|
||||
if ((protection & B_WRITE_AREA) != 0)
|
||||
kernelProtection |= B_KERNEL_WRITE_AREA;
|
||||
|
||||
// If this is a kernel area we return only the kernel flags.
|
||||
if (area->address_space == VMAddressSpace::Kernel())
|
||||
return kernelProtection;
|
||||
}
|
||||
|
||||
return protection | B_KERNEL_READ_AREA
|
||||
| (protection & B_WRITE_AREA ? B_KERNEL_WRITE_AREA : 0);
|
||||
return protection | kernelProtection;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user