diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index 44397ad..c3caba3 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -426,6 +426,10 @@ syscall_mmap (int fd, void *addr) if (file_size == 0) return MMAP_FAILURE; + /* ensures the page for mmap does not overlap with the stack */ + if (addr >= (thread_current ()->curr_esp - PGSIZE)) + return MMAP_FAILURE; + /* Check and ensure that there is enough space in the user virtual memory to hold the entire file. */ for (off_t ofs = 0; ofs < file_size; ofs += PGSIZE)