Kernel: Appreciate setuid and setgid bits executables
This commit is contained in:
parent
0dc168a8c0
commit
24b71d1170
|
@ -203,6 +203,14 @@ namespace LibELF
|
||||||
m_loaded = true;
|
m_loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LoadableELF::update_suid_sgid(Kernel::Credentials& credentials)
|
||||||
|
{
|
||||||
|
if (m_inode->mode().mode & +Inode::Mode::ISUID)
|
||||||
|
credentials.set_euid(m_inode->uid());
|
||||||
|
if (m_inode->mode().mode & +Inode::Mode::ISGID)
|
||||||
|
credentials.set_egid(m_inode->gid());
|
||||||
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<void> LoadableELF::load_page_to_memory(vaddr_t address)
|
BAN::ErrorOr<void> LoadableELF::load_page_to_memory(vaddr_t address)
|
||||||
{
|
{
|
||||||
for (const auto& program_header : m_program_headers)
|
for (const auto& program_header : m_program_headers)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <BAN/UniqPtr.h>
|
#include <BAN/UniqPtr.h>
|
||||||
#include <BAN/Vector.h>
|
#include <BAN/Vector.h>
|
||||||
|
|
||||||
|
#include <kernel/Credentials.h>
|
||||||
#include <kernel/FS/Inode.h>
|
#include <kernel/FS/Inode.h>
|
||||||
#include <kernel/Memory/PageTable.h>
|
#include <kernel/Memory/PageTable.h>
|
||||||
|
|
||||||
|
@ -30,6 +31,8 @@ namespace LibELF
|
||||||
bool is_address_space_free() const;
|
bool is_address_space_free() const;
|
||||||
void reserve_address_space();
|
void reserve_address_space();
|
||||||
|
|
||||||
|
void update_suid_sgid(Kernel::Credentials&);
|
||||||
|
|
||||||
BAN::ErrorOr<void> load_page_to_memory(Kernel::vaddr_t address);
|
BAN::ErrorOr<void> load_page_to_memory(Kernel::vaddr_t address);
|
||||||
|
|
||||||
BAN::ErrorOr<BAN::UniqPtr<LoadableELF>> clone(Kernel::PageTable&);
|
BAN::ErrorOr<BAN::UniqPtr<LoadableELF>> clone(Kernel::PageTable&);
|
||||||
|
|
|
@ -474,6 +474,7 @@ namespace Kernel
|
||||||
MUST(sys_kill(pid(), SIGKILL));
|
MUST(sys_kill(pid(), SIGKILL));
|
||||||
}
|
}
|
||||||
m_loadable_elf->reserve_address_space();
|
m_loadable_elf->reserve_address_space();
|
||||||
|
m_loadable_elf->update_suid_sgid(m_credentials);
|
||||||
m_userspace_info.entry = m_loadable_elf->entry_point();
|
m_userspace_info.entry = m_loadable_elf->entry_point();
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(m_signal_handlers) / sizeof(*m_signal_handlers); i++)
|
for (size_t i = 0; i < sizeof(m_signal_handlers) / sizeof(*m_signal_handlers); i++)
|
||||||
|
|
Loading…
Reference in New Issue