From 4bceac3d56b64ff2b373b8159057ada1493c5b47 Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Mon, 10 Jul 2023 01:34:19 -0700 Subject: [PATCH] [kernel] Check for null handle arg in mailbox_call The handle argument to `mailbox_call` is optional, so needs to be manually checked by the syscall handler before dereferencing. --- src/kernel/syscalls/mailbox.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/kernel/syscalls/mailbox.cpp b/src/kernel/syscalls/mailbox.cpp index ed45f72..1a5b819 100644 --- a/src/kernel/syscalls/mailbox.cpp +++ b/src/kernel/syscalls/mailbox.cpp @@ -39,7 +39,9 @@ mailbox_call( data.tag = *tag; data.subtag = *subtag; - data.handle = *handle; + + if (handle) + data.handle = *handle; j6_status_t s = self->call(); if (s != j6_status_ok) @@ -47,8 +49,11 @@ mailbox_call( *tag = data.tag; *subtag = data.subtag; - *handle = data.handle; - process::current().add_handle(*handle); + + if (handle) { + *handle = data.handle; + process::current().add_handle(*handle); + } return j6_status_ok; }