Kernel: verify that loaded elfs are executable

This commit is contained in:
Bananymous 2023-06-05 19:15:32 +03:00
parent 2f2c298c68
commit 649f08ec78
1 changed files with 12 additions and 0 deletions

View File

@ -53,6 +53,12 @@ namespace Kernel
delete elf; delete elf;
return BAN::Error::from_errno(EINVAL); 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(); auto* process = create_process();
MUST(process->m_working_directory.push_back('/')); MUST(process->m_working_directory.push_back('/'));
@ -212,6 +218,12 @@ namespace Kernel
delete elf; delete elf;
return BAN::Error::from_errno(EINVAL); 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); LockGuard lock_guard(m_lock);