From b988b821372466ed58eb1d2116bcbb158f70346c Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 24 Aug 2021 19:05:46 +0200 Subject: switch to using user_ptr for pointers coming from userland this avoid accidental dereferences, and now it's easy to tell apart which pointers are safe to directly read and which aren't. cons: - const is completely discarded --- src/kernel/arch/generic.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/kernel/arch/generic.h') diff --git a/src/kernel/arch/generic.h b/src/kernel/arch/generic.h index 1fa716b..e7afeff 100644 --- a/src/kernel/arch/generic.h +++ b/src/kernel/arch/generic.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -22,11 +23,11 @@ int syscall_handler(int, int, int, int); // all of those can allocate memory struct pagedir *pagedir_new(void); struct pagedir *pagedir_copy(const struct pagedir *orig); -void pagedir_map(struct pagedir *dir, void *virt, void *phys, +void pagedir_map(struct pagedir *dir, user_ptr virt, void *phys, bool user, bool writeable); void pagedir_switch(struct pagedir *); // return 0 on failure -void *pagedir_virt2phys(struct pagedir *dir, const void *virt, +void *pagedir_virt2phys(struct pagedir *dir, const user_ptr virt, bool user, bool writeable); -- cgit v1.2.3