From f6d372b2ab0fb6a4cc17b4391c379586cc91e7c3 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Fri, 4 Jun 2021 22:51:04 +0200 Subject: [PATCH] Kernel: Process::exec(): Check if path is a regular file https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html [EACCES] The new process image file is not a regular file and the implementation does not support execution of files of its type. Let's check whether the passed `path` is indeed a regular file. --- Kernel/Syscalls/execve.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index 394d70958e..ba6b0f72cc 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -827,6 +827,9 @@ KResult Process::exec(String path, Vector arguments, Vector envi auto description = file_or_error.release_value(); auto metadata = description->metadata(); + if (!metadata.is_regular_file()) + return EACCES; + // Always gonna need at least 3 bytes. these are for #!X if (metadata.size < 3) return ENOEXEC;