Skip to content

Commit 4b80d28

Browse files
committed
Fix invalid mapping to zero page caused by off-by-one bug
The `zero_end` bound is exclusive, but we treat the `end_page` as inclusive. So when `zero_end` is page-aligned, we allocate one additional bss page. If this page was already mapped to some other segment, we remap it to a page with random content. This is the same bug as #362.
1 parent 3531dfb commit 4b80d28

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: src/page_table.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ pub(crate) fn map_segment(
187187
zero_start.as_u64(),
188188
Size4KiB::SIZE,
189189
)));
190-
let end_page = Page::containing_address(zero_end);
190+
let end_page = Page::containing_address(zero_end - 1usize);
191191
for page in Page::range_inclusive(start_page, end_page) {
192192
let frame = frame_allocator
193193
.allocate_frame(MemoryRegionType::Kernel)

0 commit comments

Comments
 (0)