syscalls: misc vulnerability fixes

This commit is contained in:
Matheus
2026-04-28 21:27:51 -03:00
parent 02a47c8303
commit 42cec91cb9
6 changed files with 13 additions and 8 deletions
+2 -4
View File
@@ -12,15 +12,13 @@ syscallret_t syscall_clockget(context_t *, int clockid, timespec_t *tp) {
switch (clockid) {
case CLOCK_REALTIME: {
timespec_t ts = timekeeper_time();
usercopy_touser(tp, &ts, sizeof(timespec_t));
ret.errno = 0;
ret.errno = usercopy_touser(tp, &ts, sizeof(timespec_t));
break;
}
case CLOCK_MONOTONIC:
case CLOCK_BOOTTIME: {
timespec_t ts = timekeeper_timefromboot();
usercopy_touser(tp, &ts, sizeof(timespec_t));
ret.errno = 0;
ret.errno = usercopy_touser(tp, &ts, sizeof(timespec_t));
break;
}
default: {
+1
View File
@@ -11,6 +11,7 @@ syscallret_t syscall_getsockopt(context_t *, int fd, int level, int optname, voi
if (!IS_USER_ADDRESS(val) || !IS_USER_ADDRESS(len)) {
ret.errno = EFAULT;
return ret;
}
file_t *file = fd_get(fd);
+3 -2
View File
@@ -59,10 +59,11 @@ syscallret_t syscall_hostname(context_t *, char *unew, size_t newsize, char *uol
spinlock_release(&lock);
interrupt_set(true);
ret.errno = 0;
if (uold)
ret.errno = usercopy_touser(uold, old, copysize + 1);
ret.errno = 0;
ret.ret = 0;
ret.ret = ret.errno ? -1 : 0;
return ret;
}
+5
View File
@@ -9,6 +9,11 @@ syscallret_t syscall_kill(context_t *context, int pid, int signal) {
.ret = -1
};
if (signal >= NSIG) {
ret.errno = EINVAL;
return ret;
}
int effectivepid = -1;
if (pid > 0) // specific process
+1 -1
View File
@@ -9,7 +9,7 @@ syscallret_t syscall_killthread(context_t *context, int pid, int tid, int signal
.ret = -1
};
if (pid < 1 || tid < 1 || signal < 0 || signal > NSIG) {
if (pid < 1 || tid < 1 || signal < 0 || signal >= NSIG) {
ret.errno = EINVAL;
return ret;
}
+1 -1
View File
@@ -7,7 +7,7 @@ syscallret_t syscall_sigaction(context_t *, int sig, sigaction_t *new, sigaction
.ret = -1
};
if (sig > NSIG || sig == SIGKILL || sig == SIGSTOP) {
if (sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) {
ret.errno = EINVAL;
return ret;
}