From 0e6e1092f0af0c69a639105bc16bd9efcf1ad690 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sat, 27 Nov 2021 11:22:25 +0100 Subject: Kernel: Make ptrace return an error on error Returning 'result.error().code()' erroneously creates an ErrorOr of the positive errno code, which breaks our error-returning convention. This seems to be due to a forgotten minus-sign during the refactoring in 9e51e295cfe2775ff179b10f1cd90368cfb102ad. This latent bug was never discovered, because currently the error-handling paths are rarely exercised. --- Kernel/Syscalls/ptrace.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Kernel/Syscalls') diff --git a/Kernel/Syscalls/ptrace.cpp b/Kernel/Syscalls/ptrace.cpp index 0eede17a7c..2eb53c3b85 100644 --- a/Kernel/Syscalls/ptrace.cpp +++ b/Kernel/Syscalls/ptrace.cpp @@ -162,8 +162,7 @@ ErrorOr Process::sys$ptrace(Userspace REQUIRE_PROMISE(ptrace); auto params = TRY(copy_typed_from_user(user_params)); - auto result = handle_ptrace(params, *this); - return result.is_error() ? result.error().code() : result.value(); + return handle_ptrace(params, *this); } /** -- cgit v1.2.3