Update validate_user_pointer to check if the ptr is mapped to a physical memory address, w/ E

This commit is contained in:
sBubshait
2024-11-08 14:21:16 +00:00
parent 39018419cd
commit 26e38be761

View File

@@ -5,6 +5,7 @@
#include "threads/interrupt.h" #include "threads/interrupt.h"
#include "threads/thread.h" #include "threads/thread.h"
#include "userprog/process.h" #include "userprog/process.h"
#include "userprog/pagedir.h"
#include <stdio.h> #include <stdio.h>
#include <syscall-nr.h> #include <syscall-nr.h>
@@ -227,8 +228,9 @@ validate_user_pointer (const void *ptr, size_t size)
{ {
if (size > 0 && (ptr == NULL || if (size > 0 && (ptr == NULL ||
!is_user_vaddr (ptr) || !is_user_vaddr (ptr) ||
!is_user_vaddr (ptr + size - 1))) !is_user_vaddr (ptr + size - 1) ||
pagedir_get_page (thread_current()->pagedir, ptr) == NULL))
thread_exit (); thread_exit ();
return ptr; return (void *) ptr;
} }