Fix sys_mprotect with page alignment, dynamic loading seems working

master
Jiajie Chen 6 years ago
parent d285adf277
commit 08ba9261aa

@ -72,7 +72,7 @@ impl MemoryArea {
.map(|s| String::from(s))
}
/// Test whether this area is (page) overlap with area [`start_addr`, `end_addr`]
fn is_overlap_with(&self, start_addr: VirtAddr, end_addr: VirtAddr) -> bool {
pub fn is_overlap_with(&self, start_addr: VirtAddr, end_addr: VirtAddr) -> bool {
let p0 = Page::of_addr(self.start_addr);
let p1 = Page::of_addr(self.end_addr - 1) + 1;
let p2 = Page::of_addr(start_addr);

@ -84,7 +84,7 @@ pub fn sys_mprotect(addr: usize, len: usize, prot: usize) -> SysResult {
// FIXME: properly set the attribute of the area
// now some mut ptr check is fault
let memory_area = proc.vm.iter().find(|area| area.contains(addr));
let memory_area = proc.vm.iter().find(|area| area.is_overlap_with(addr, addr + len));
if memory_area.is_none() {
return Err(SysError::ENOMEM);
}

@ -1 +1 @@
Subproject commit 4bcc820a8b316c177cc5d82ee5edbbe0ac551814
Subproject commit 835568e2059ef872320e41517e826ced0768e357
Loading…
Cancel
Save