From 434b79c0be7fdd72dd965615104b00f52b1dc4c3 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 10 Apr 2024 17:04:22 -0400 Subject: kernel: Get rid of invalid_uaddr() Use signal_raise(NULL, SIGSEGV) instead Signed-off-by: Ian Moffett --- sys/include/sys/system.h | 9 --------- sys/kern/kern_filedesc.c | 7 ++++--- 2 files changed, 4 insertions(+), 12 deletions(-) (limited to 'sys') diff --git a/sys/include/sys/system.h b/sys/include/sys/system.h index 4e34c30..c2e47c2 100644 --- a/sys/include/sys/system.h +++ b/sys/include/sys/system.h @@ -32,15 +32,6 @@ #include -/* - * TODO: Get rid of this when signals are implemented, - * it is best to segfault the program when this - * happens. - */ -#define invalid_uaddr(UADDR) \ - panic("invalid uaddr 0x%p (pid=%d)\n", \ - UADDR, this_td()->pid); - #if defined(_KERNEL) int copyin(uintptr_t uaddr, void *kaddr, size_t len); int copyout(const void *kaddr, uintptr_t uaddr, size_t len); diff --git a/sys/kern/kern_filedesc.c b/sys/kern/kern_filedesc.c index 3401f0b..8e15d48 100644 --- a/sys/kern/kern_filedesc.c +++ b/sys/kern/kern_filedesc.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -79,7 +80,7 @@ make_write_buf(struct proc *td, const void *data, char **buf_out, size_t count) * and use copyin() */ if (copyin((uintptr_t)data, buf, count) != 0) { - invalid_uaddr(data); + signal_raise(NULL, SIGSEGV); } } else { /* Can just memcpy() here */ @@ -413,7 +414,7 @@ sys_open(struct syscall_args *args) } if (copyinstr(args->arg0, pathbuf, PATH_MAX) != 0) { - invalid_uaddr(args->arg0); + signal_raise(NULL, SIGSEGV); } ret = open(pathbuf, args->arg1); @@ -461,7 +462,7 @@ sys_read(struct syscall_args *args) return bytes_read; } if (copyout(kbuf, args->arg1, bytes_read) != 0) { - invalid_uaddr(args->arg1); + signal_raise(NULL, SIGSEGV); } dynfree(kbuf); -- cgit v1.2.3