summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authordzwdz2021-08-24 19:05:46 +0200
committerdzwdz2021-08-24 19:05:46 +0200
commitb988b821372466ed58eb1d2116bcbb158f70346c (patch)
tree669bb9331082848277031632e818e8293fb6e44c /src/shared
parent04878a07e587f26fe6d5a1044b69651406e3aa1c (diff)
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
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/syscalls.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/shared/syscalls.h b/src/shared/syscalls.h
index 9eb3fa5..d0c6640 100644
--- a/src/shared/syscalls.h
+++ b/src/shared/syscalls.h
@@ -1,3 +1,5 @@
+// requires the user_ptr type from kernel/types.h or init/types.h
+
#pragma once
#include <stddef.h>
@@ -21,12 +23,12 @@ enum {
/** Kills the current process.
* TODO: what happens to the children?
*/
-_Noreturn void _syscall_exit(const char *msg, size_t len);
+_Noreturn void _syscall_exit(const user_ptr msg, size_t len);
/** Waits for a child to exit, putting its exit message into *buf.
* @return the length of the message
*/
-int _syscall_await(char *buf, int len);
+int _syscall_await(user_ptr buf, int len);
/** Creates a copy of the current process, and executes it.
* All user memory pages get copied too.
@@ -34,9 +36,9 @@ int _syscall_await(char *buf, int len);
*/
int _syscall_fork(void);
-fd_t _syscall_fs_open(const char *path, int len);
-int _syscall_mount(const char *path, int len, fd_t fd);
+fd_t _syscall_fs_open(const user_ptr path, int len);
+int _syscall_mount(const user_ptr path, int len, fd_t fd);
-int _syscall_fd_read(fd_t fd, char *buf, int len);
-int _syscall_fd_write(fd_t fd, char *buf, int len);
+int _syscall_fd_read(fd_t fd, user_ptr buf, int len);
+int _syscall_fd_write(fd_t fd, user_ptr buf, int len);
int _syscall_fd_close(fd_t fd);