From Michael Lotz <mmlr@xxxxxxxx>:
Michael Lotz has uploaded this change for review. (
https://review.haiku-os.org/c/haiku/+/3167 ;)
Change subject: kernel/vm: Avoid page protection overflows for very large areas.
......................................................................
kernel/vm: Avoid page protection overflows for very large areas.
For areas >= 32TiB the page protection array size would overflow.
---
M src/system/kernel/vm/vm.cpp
1 file changed, 3 insertions(+), 3 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/67/3167/1
diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp
index 36d8a31..37f2632 100644
--- a/src/system/kernel/vm/vm.cpp
+++ b/src/system/kernel/vm/vm.cpp
@@ -462,7 +462,7 @@
{
// In the page protections we store only the three user protections,
// so we use 4 bits per page.
- uint32 bytes = (area->Size() / B_PAGE_SIZE + 1) / 2;
+ size_t bytes = (area->Size() / B_PAGE_SIZE + 1) / 2;
area->page_protections = (uint8*)malloc_etc(bytes,
HEAP_DONT_LOCK_KERNEL_SPACE);
if (area->page_protections == NULL)
@@ -481,7 +481,7 @@
set_area_page_protection(VMArea* area, addr_t pageAddress, uint32 protection)
{
protection &= B_READ_AREA | B_WRITE_AREA | B_EXECUTE_AREA;
- uint32 pageIndex = (pageAddress - area->Base()) / B_PAGE_SIZE;
+ addr_t pageIndex = (pageAddress - area->Base()) / B_PAGE_SIZE;
uint8& entry = area->page_protections[pageIndex / 2];
if (pageIndex % 2 == 0)
entry = (entry & 0xf0) | protection;
@@ -5228,7 +5228,7 @@
if (status == B_OK) {
// Shrink or grow individual page protections if in use.
if (area->page_protections != NULL) {
- uint32 bytes = (newSize / B_PAGE_SIZE + 1) / 2;
+ size_t bytes = (newSize / B_PAGE_SIZE + 1) / 2;
uint8* newProtections
= (uint8*)realloc(area->page_protections,
bytes);
if (newProtections == NULL)
--
To view, visit https://review.haiku-os.org/c/haiku/+/3167
To unsubscribe, or for help writing mail filters, visit
https://review.haiku-os.org/settings
Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: Ic95d9a6e35bbedb165c2bbd382f6c47edde07ac2
Gerrit-Change-Number: 3167
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Lotz <mmlr@xxxxxxxx>
Gerrit-MessageType: newchange