Add Fixes to Memory Leaks, Memory Access Validation, Synchronised Processes and Refactoring #38

Merged
sb3923 merged 12 commits from system-calls into userprog-oom 2024-11-13 19:20:20 +00:00
15 changed files with 208 additions and 70 deletions
Showing only changes of commit fa2fb4a711 - Show all commits

View File

@@ -91,7 +91,7 @@ syscall_init (void)
lock_init (&filesys_lock); lock_init (&filesys_lock);
} }
/* Function that takes a interrupt frame containing a syscall and its args. /* Function that takes an interrupt frame containing a syscall and its args.
Validates the arguments and pointers before calling the relevant Validates the arguments and pointers before calling the relevant
high-level system call function, storing its output (if any) in f->eax */ high-level system call function, storing its output (if any) in f->eax */
static void static void
@@ -138,8 +138,7 @@ syscall_exit (int status)
} }
/* Executes a given command with the relevant args, by calling process_execute. /* Executes a given command with the relevant args, by calling process_execute.
Returns PID for the process that is running the CMD_LINE Returns PID for the process that is running the CMD_LINE. */
*/
static pid_t static pid_t
syscall_exec (const char *cmd_line) syscall_exec (const char *cmd_line)
{ {
@@ -416,8 +415,8 @@ fd_get_file (int fd)
} }
/* Validates if a block of memory starting at START and of size SIZE bytes is /* Validates if a block of memory starting at START and of size SIZE bytes is
fully contained within user virtual memory. Kills the thread (by calling fully contained within user virtual memory. Kills the thread (by exiting with
thread_exit) if the memory is invalid. Otherwise, returns (nothing) normally. failure) if the memory is invalid. Otherwise, returns (nothing) normally.
If the size is 0, the function does no checks and returns the given ptr. */ If the size is 0, the function does no checks and returns the given ptr. */
static void static void
validate_user_pointer (const void *start, size_t size) validate_user_pointer (const void *start, size_t size)
@@ -438,7 +437,7 @@ validate_user_pointer (const void *start, size_t size)
} }
/* Validates if a string is fully contained within user virtual memory. Kills /* Validates if a string is fully contained within user virtual memory. Kills
the thread (by calling thread_exit) if the memory is invalid. Otherwise, the thread (by exiting with failure) if the memory is invalid. Otherwise,
returns (nothing) normally. */ returns (nothing) normally. */
static void static void
validate_user_string (const char *str) validate_user_string (const char *str)