From 1bea780a7f1add99a4faccde7bec010869b837db Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Fri, 15 Dec 2023 17:38:24 +0200 Subject: [PATCH] Kernel: Reject loading ELF files with no loadable segments If there's no loadable segments then there can't be any code to execute either. This resolves a crash these kinds of ELF files would cause from the directly following VERIFY statement. --- Kernel/Syscalls/execve.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index 0602fa2188..297f9ed8f7 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -201,6 +201,10 @@ static ErrorOr get_required_load_range(OpenFileDescription& p range.end = region_end; }); + // If there's nothing to load, there's nothing to execute + if (range.start == range.end) + return EINVAL; + VERIFY(range.end > range.start); return range; }