From cd9ecc1746a3552dc1c53f8904bc1c332f807137 Mon Sep 17 00:00:00 2001 From: apio Date: Thu, 20 Oct 2022 08:20:56 +0200 Subject: [PATCH] Kernel: Return EFAULT when the kernel believes the wstatus pointer is invalid --- kernel/src/thread/Scheduler.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/src/thread/Scheduler.cpp b/kernel/src/thread/Scheduler.cpp index 27498097..5433353e 100644 --- a/kernel/src/thread/Scheduler.cpp +++ b/kernel/src/thread/Scheduler.cpp @@ -490,7 +490,13 @@ void sys_waitpid(Context* context, long pid, int* wstatus, *kwstatus = (int)(child->exit_status & 0xff); release_user_ref(kwstatus); } - else { kinfoln("wstatus ptr is invalid: %p", (void*)wstatus); } + else + { + kinfoln("wstatus ptr is invalid: %p", (void*)wstatus); + child->state = child->Exited; + context->rax = -EFAULT; + return; + } } child->state = child->Exited; context->rax = (long)child->id;