summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-08-19 22:45:07 +0300
committerAndreas Kling <kling@serenityos.org>2021-08-19 23:49:53 +0200
commitcf271183b4befeba7c96bd6ca25246b899e836bb (patch)
tree0361e7378750c2c4e45e5e01e273d6fe416555af /Kernel/Syscalls
parent1259dc362376e8011d20d4d9e2fcc49d5b7f9dc9 (diff)
downloadserenity-cf271183b4befeba7c96bd6ca25246b899e836bb.zip
Kernel: Make Process::current() return a Process& instead of Process*
This has several benefits: 1) We no longer just blindly derefence a null pointer in various places 2) We will get nicer runtime error messages if the current process does turn out to be null in the call location 3) GCC no longer complains about possible nullptr dereferences when compiling without KUBSAN
Diffstat (limited to 'Kernel/Syscalls')
-rw-r--r--Kernel/Syscalls/fcntl.cpp2
-rw-r--r--Kernel/Syscalls/ptrace.cpp2
-rw-r--r--Kernel/Syscalls/thread.cpp6
3 files changed, 3 insertions, 7 deletions
diff --git a/Kernel/Syscalls/fcntl.cpp b/Kernel/Syscalls/fcntl.cpp
index 61a9a6ef99..c2d59bda0f 100644
--- a/Kernel/Syscalls/fcntl.cpp
+++ b/Kernel/Syscalls/fcntl.cpp
@@ -47,7 +47,7 @@ KResultOr<FlatPtr> Process::sys$fcntl(int fd, int cmd, u32 arg)
case F_GETLK:
return description->get_flock(Userspace<flock*>(arg));
case F_SETLK:
- return description->apply_flock(*Process::current(), Userspace<const flock*>(arg));
+ return description->apply_flock(Process::current(), Userspace<const flock*>(arg));
default:
return EINVAL;
}
diff --git a/Kernel/Syscalls/ptrace.cpp b/Kernel/Syscalls/ptrace.cpp
index 32919cd7d5..f9e9ffed48 100644
--- a/Kernel/Syscalls/ptrace.cpp
+++ b/Kernel/Syscalls/ptrace.cpp
@@ -20,7 +20,7 @@ static KResultOr<u32> handle_ptrace(const Kernel::Syscall::SC_ptrace_params& par
{
ScopedSpinLock scheduler_lock(g_scheduler_lock);
if (params.request == PT_TRACE_ME) {
- if (Process::current()->tracer())
+ if (Process::current().tracer())
return EBUSY;
caller.set_wait_for_tracer_at_next_execve(true);
diff --git a/Kernel/Syscalls/thread.cpp b/Kernel/Syscalls/thread.cpp
index ec4b567f03..7a8fcbe3ec 100644
--- a/Kernel/Syscalls/thread.cpp
+++ b/Kernel/Syscalls/thread.cpp
@@ -168,12 +168,8 @@ KResultOr<FlatPtr> Process::sys$kill_thread(pid_t tid, int signal)
if (!thread || thread->pid() != pid())
return ESRCH;
- auto process = Process::current();
- if (!process)
- return ESRCH;
-
if (signal != 0)
- thread->send_signal(signal, process);
+ thread->send_signal(signal, &Process::current());
return 0;
}