Implement function to validate user memory pointers w/ S.

This commit is contained in:
EDiasAlberto
2024-11-03 23:20:42 +00:00
parent 62453ef432
commit 87126237ad

View File

@@ -1,5 +1,6 @@
#include "userprog/syscall.h"
#include "devices/shutdown.h"
#include "threads/vaddr.h"
#include <stdio.h>
#include <syscall-nr.h>
#include "threads/interrupt.h"
@@ -51,4 +52,15 @@ static void
exit (int status)
{
//TODO
}
/* A function to validate if a block of memory starting at PTR and of
size SIZE bytes is fully contained within user virtual memory. */
static void *
validate_user_pointer (void *ptr, size_t size)
{
if (ptr == NULL || !is_user_vaddr (ptr) || !is_user_vaddr (ptr + size - 1))
thread_exit ();
return ptr;
}