summaryrefslogtreecommitdiff
path: root/src/kernel/syscalls.c
diff options
context:
space:
mode:
authordzwdz2024-07-13 23:37:37 +0200
committerdzwdz2024-07-13 23:37:37 +0200
commitc1d3ac750b8483c9a942d2fb5d5b7245d014e905 (patch)
tree630fb27832e15f3dfde0b0723c5e08a4421e8d22 /src/kernel/syscalls.c
parentded843efbdad1ed048fe42c50c8fb68d50bafa51 (diff)
kernel/malloc: limit the maximum allocation size to under a page
This will likely be changed back, but for the time being it will let me implement a better allocator without too much effort.
Diffstat (limited to 'src/kernel/syscalls.c')
-rw-r--r--src/kernel/syscalls.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index 5771b6a..7fcbd2a 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -62,6 +62,7 @@ hid_t _sys_open(const char __user *path, long len, int flags) {
if (flags & ~(OPEN_RW | OPEN_CREATE)) SYSCALL_RETURN(-ENOSYS);
+ static_assert(PATH_MAX <= KMALLOC_MAX);
if (PATH_MAX < len)
SYSCALL_RETURN(-ENAMETOOLONG);
/* Doesn't check for free handles. Another thread could use up all
@@ -461,7 +462,8 @@ hid_t _sys_getnull(int flags) {
long _sys_execbuf(void __user *ubuf, size_t len) {
if (len == 0) SYSCALL_RETURN(0);
- if (len > EXECBUF_MAX_LEN)
+ static_assert(EXECBUF_MAX_LEN <= KMALLOC_MAX);
+ if (EXECBUF_MAX_LEN < len)
SYSCALL_RETURN(-1);
if (proc_cur->execbuf.buf)
SYSCALL_RETURN(-1);