summaryrefslogtreecommitdiffstats
path: root/sys/syscall.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/syscall.c')
-rw-r--r--sys/syscall.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/sys/syscall.c b/sys/syscall.c
index 31f9078..5cef3d6 100644
--- a/sys/syscall.c
+++ b/sys/syscall.c
@@ -1,7 +1,7 @@
#include "sys/syscall.h"
#include "arch/x86_64/hal/obj.h"
#include "hal/smp.h"
-#include "hal/process.h"
+#include "proc/process.h"
#include "jove.h"
#include "lib/printf.h"
#include "sys/link.h"
@@ -83,14 +83,12 @@ syscall_handler(uintmax_t message_path_raw, uint16_t message_pathlen)
int sysret = 0;
- ctx.pcb = lockstack_push(&ctx.lockstack, process_current());
+ ctx.pcb = process_current();
pcb_t *pcb = obj_deref(ctx.pcb);
ctx.objdir = lockstack_push(&ctx.lockstack, obj_take(pcb_rootdir(pcb)));
- ctx.message = link_try_traverse(
- lockstack_push(&ctx.lockstack, objdir_trygetobj(
- ctx.objdir, message_path, message_pathlen)),
- &ctx.lockstack);
+ ctx.message = link_try_traverse_objdir(
+ ctx.objdir, &ctx.lockstack, message_pathlen, message_path);
if(ctx.message.obj == NULL) {
klogf("Process %i failed to get message %P : %s\n",
@@ -106,6 +104,13 @@ syscall_handler(uintmax_t message_path_raw, uint16_t message_pathlen)
goto release_return;
}
+ if((ctx.message.permissions & JOVE_PERM_READ) == 0) {
+ klogf("Process %i tried to call syscall with message object %P without read permissions\n",
+ pcb_pid(pcb), message_path, message_pathlen);
+ sysret = -EPERM;
+ goto release_return;
+ }
+
size_t messagelen = message_len(ctx.message.obj);
void *messagedata = message_data(ctx.message.obj);
struct syscall_header *header = messagedata;
@@ -122,8 +127,9 @@ syscall_handler(uintmax_t message_path_raw, uint16_t message_pathlen)
ctx.bytes_left = messagelen - bytes_needed;
ctx.payload = (void*)((uintptr_t)header + bytes_needed);
- ctx.target.obj = lockstack_push(&ctx.lockstack,
- objdir_trygetobj(ctx.objdir, header->path, header->pathlen));
+ ctx.target = link_try_traverse_objdir(
+ ctx.objdir, &ctx.lockstack, ctx.header->pathlen, ctx.header->path);
+
if(ctx.target.obj == 0) {
//Could not find payload target in pcb rootdir.
klogf("Process %i tried to call syscall with bad target path %P : %s\n",
@@ -132,7 +138,6 @@ syscall_handler(uintmax_t message_path_raw, uint16_t message_pathlen)
goto release_return;
}
- ctx.target.permissions = JOVE_PERM_ALL;
sysret = _syscall_handle_switch(&ctx);
release_return: