From 08a806e75df88aa92244ac6dec5973a4f10e302a Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 5 Jun 2023 19:15:32 +0300 Subject: [PATCH] Kernel: verify that loaded elfs are executable --- kernel/kernel/Process.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index ebdba27d..8c0d6c63 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -53,6 +53,12 @@ namespace Kernel delete elf; return BAN::Error::from_errno(EINVAL); } + if (elf->file_header_native().e_type != LibELF::ET_EXEC) + { + derrorln("Not an executable"); + delete elf; + return BAN::Error::from_errno(EINVAL); + } auto* process = create_process(); MUST(process->m_working_directory.push_back('/')); @@ -212,6 +218,12 @@ namespace Kernel delete elf; return BAN::Error::from_errno(EINVAL); } + if (elf->file_header_native().e_type != LibELF::ET_EXEC) + { + derrorln("Not an executable"); + delete elf; + return BAN::Error::from_errno(EINVAL); + } LockGuard lock_guard(m_lock);