diff --git a/crate/memory/src/memory_set/mod.rs b/crate/memory/src/memory_set/mod.rs index 63c9946..4bc7afb 100644 --- a/crate/memory/src/memory_set/mod.rs +++ b/crate/memory/src/memory_set/mod.rs @@ -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); diff --git a/kernel/src/syscall/mem.rs b/kernel/src/syscall/mem.rs index 986e56c..457131f 100644 --- a/kernel/src/syscall/mem.rs +++ b/kernel/src/syscall/mem.rs @@ -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); } diff --git a/user b/user index 4bcc820..835568e 160000 --- a/user +++ b/user @@ -1 +1 @@ -Subproject commit 4bcc820a8b316c177cc5d82ee5edbbe0ac551814 +Subproject commit 835568e2059ef872320e41517e826ced0768e357