diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index daf6a8e..85deffc 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -81,7 +81,6 @@ static const syscall_arguments syscall_lookup[] = static const int LOOKUP_SIZE = sizeof (syscall_lookup) / sizeof (syscall_arguments); - /* Initialises the syscall handling system, as well as a global lock to synchronise all file access between processes. */ void @@ -103,13 +102,14 @@ syscall_handler (struct intr_frame *f) /* Ensures the number corresponds to a system call that can be handled. */ if (syscall_number >= LOOKUP_SIZE) - thread_exit (); + syscall_exit (EXIT_FAILURE); syscall_arguments syscall = syscall_lookup[syscall_number]; /* Next, read and copy the arguments from the stack pointer. */ validate_user_pointer (f->esp + sizeof (uintptr_t), syscall.arity * sizeof (uintptr_t)); + uintptr_t args[MAX_SYSCALL_ARGS] = {0}; for (int i = 0; i < syscall.arity && i < MAX_SYSCALL_ARGS; i++) args[i] = *(uintptr_t *) (f->esp + sizeof (uintptr_t) * (i + 1)); @@ -427,13 +427,13 @@ validate_user_pointer (const void *start, size_t size) const void *end = start + size - 1; if (start == NULL || !is_user_vaddr (start) || !is_user_vaddr (end)) - thread_exit (); + syscall_exit (EXIT_FAILURE); /* We now need to check if the entire memory block is mapped to physical memory by the page table. */ for (const void *ptr = start; ptr <= end; ptr += PGSIZE) if (pagedir_get_page (thread_current ()->pagedir, ptr) == NULL) - thread_exit (); + syscall_exit (EXIT_FAILURE); } /* Validates if a string is fully contained within user virtual memory. Kills @@ -443,7 +443,7 @@ static void validate_user_string (const char *str) { if (str == NULL || !is_user_vaddr (str)) - thread_exit (); + syscall_exit (EXIT_FAILURE); size_t length = 0; size_t offset = (uintptr_t) str % PGSIZE; @@ -455,7 +455,7 @@ validate_user_string (const char *str) if (!is_user_vaddr(page) || pagedir_get_page (thread_current ()->pagedir, page) == NULL) - thread_exit (); + syscall_exit (EXIT_FAILURE); while (offset < PGSIZE) {