mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
syscalls: misc vulnerability fixes
This commit is contained in:
@@ -12,15 +12,13 @@ syscallret_t syscall_clockget(context_t *, int clockid, timespec_t *tp) {
|
|||||||
switch (clockid) {
|
switch (clockid) {
|
||||||
case CLOCK_REALTIME: {
|
case CLOCK_REALTIME: {
|
||||||
timespec_t ts = timekeeper_time();
|
timespec_t ts = timekeeper_time();
|
||||||
usercopy_touser(tp, &ts, sizeof(timespec_t));
|
ret.errno = usercopy_touser(tp, &ts, sizeof(timespec_t));
|
||||||
ret.errno = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CLOCK_MONOTONIC:
|
case CLOCK_MONOTONIC:
|
||||||
case CLOCK_BOOTTIME: {
|
case CLOCK_BOOTTIME: {
|
||||||
timespec_t ts = timekeeper_timefromboot();
|
timespec_t ts = timekeeper_timefromboot();
|
||||||
usercopy_touser(tp, &ts, sizeof(timespec_t));
|
ret.errno = usercopy_touser(tp, &ts, sizeof(timespec_t));
|
||||||
ret.errno = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|||||||
@@ -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)) {
|
if (!IS_USER_ADDRESS(val) || !IS_USER_ADDRESS(len)) {
|
||||||
ret.errno = EFAULT;
|
ret.errno = EFAULT;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_t *file = fd_get(fd);
|
file_t *file = fd_get(fd);
|
||||||
|
|||||||
@@ -59,10 +59,11 @@ syscallret_t syscall_hostname(context_t *, char *unew, size_t newsize, char *uol
|
|||||||
spinlock_release(&lock);
|
spinlock_release(&lock);
|
||||||
interrupt_set(true);
|
interrupt_set(true);
|
||||||
|
|
||||||
|
ret.errno = 0;
|
||||||
|
|
||||||
if (uold)
|
if (uold)
|
||||||
ret.errno = usercopy_touser(uold, old, copysize + 1);
|
ret.errno = usercopy_touser(uold, old, copysize + 1);
|
||||||
|
|
||||||
ret.errno = 0;
|
ret.ret = ret.errno ? -1 : 0;
|
||||||
ret.ret = 0;
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ syscallret_t syscall_kill(context_t *context, int pid, int signal) {
|
|||||||
.ret = -1
|
.ret = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (signal >= NSIG) {
|
||||||
|
ret.errno = EINVAL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int effectivepid = -1;
|
int effectivepid = -1;
|
||||||
|
|
||||||
if (pid > 0) // specific process
|
if (pid > 0) // specific process
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ syscallret_t syscall_killthread(context_t *context, int pid, int tid, int signal
|
|||||||
.ret = -1
|
.ret = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
if (pid < 1 || tid < 1 || signal < 0 || signal > NSIG) {
|
if (pid < 1 || tid < 1 || signal < 0 || signal >= NSIG) {
|
||||||
ret.errno = EINVAL;
|
ret.errno = EINVAL;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ syscallret_t syscall_sigaction(context_t *, int sig, sigaction_t *new, sigaction
|
|||||||
.ret = -1
|
.ret = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
if (sig > NSIG || sig == SIGKILL || sig == SIGSTOP) {
|
if (sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) {
|
||||||
ret.errno = EINVAL;
|
ret.errno = EINVAL;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user