mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-08 12:12:53 +00:00
Kernel+LibC: Introduce a "dumpable" flag for processes
This new flag controls two things: - Whether the kernel will generate core dumps for the process - Whether the EUID:EGID should own the process's files in /proc Processes are automatically made non-dumpable when their EUID or EGID is changed, either via syscalls that specifically modify those ID's, or via sys$execve(), when a set-uid or set-gid program is executed. A process can change its own dumpable flag at any time by calling the new sys$prctl(PR_SET_DUMPABLE) syscall. Fixes #4504.
This commit is contained in:
parent
3c9bd911b8
commit
82f86e35d6
Notes:
sideshowbarker
2024-07-19 00:36:28 +09:00
Author: https://github.com/awesomekling
Commit: 82f86e35d6
13 changed files with 199 additions and 7 deletions
|
@ -363,19 +363,25 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
|
|||
auto old_suid = m_suid;
|
||||
auto old_egid = m_egid;
|
||||
auto old_sgid = m_sgid;
|
||||
auto was_dumpable = is_dumpable();
|
||||
|
||||
ArmedScopeGuard cred_restore_guard = [&] {
|
||||
m_euid = old_euid;
|
||||
m_suid = old_suid;
|
||||
m_egid = old_egid;
|
||||
m_sgid = old_sgid;
|
||||
set_dumpable(was_dumpable);
|
||||
};
|
||||
|
||||
if (!(main_program_description->custody()->mount_flags() & MS_NOSUID)) {
|
||||
if (main_program_metadata.is_setuid())
|
||||
if (main_program_metadata.is_setuid()) {
|
||||
set_dumpable(false);
|
||||
m_euid = m_suid = main_program_metadata.uid;
|
||||
if (main_program_metadata.is_setgid())
|
||||
}
|
||||
if (main_program_metadata.is_setgid()) {
|
||||
set_dumpable(false);
|
||||
m_egid = m_sgid = main_program_metadata.gid;
|
||||
}
|
||||
}
|
||||
|
||||
auto load_result_or_error = load(main_program_description, interpreter_description);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue