1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:38:10 +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:
Andreas Kling 2020-12-25 18:27:42 +01:00
parent 3c9bd911b8
commit 82f86e35d6
13 changed files with 199 additions and 7 deletions

View file

@ -879,6 +879,7 @@ static OwnPtr<KBuffer> procfs$all(InodeIdentifier)
process_object.add("amount_purgeable_volatile", process.amount_purgeable_volatile());
process_object.add("amount_purgeable_nonvolatile", process.amount_purgeable_nonvolatile());
process_object.add("icon_id", process.icon_id());
process_object.add("dumpable", process.is_dumpable());
auto thread_array = process_object.add_array("threads");
process.for_each_thread([&](const Thread& thread) {
auto thread_object = thread_array.add_object();
@ -1137,22 +1138,20 @@ InodeMetadata ProcFSInode::metadata() const
if (is_process_related_file(identifier())) {
ProcessID pid = to_pid(identifier());
auto process = Process::from_pid(pid);
if (process) {
if (process && process->is_dumpable()) {
metadata.uid = process->euid();
metadata.gid = process->egid();
} else {
// TODO: How to handle this?
metadata.uid = 0;
metadata.gid = 0;
}
} else if (is_thread_related_file(identifier())) {
ThreadID tid = to_tid(identifier());
auto thread = Thread::from_tid(tid);
if (thread) {
if (thread && thread->process().is_dumpable()) {
metadata.uid = thread->process().euid();
metadata.gid = thread->process().egid();
} else {
// TODO: How to handle this?
metadata.uid = 0;
metadata.gid = 0;
}