1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 12:15:09 +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

@ -192,6 +192,9 @@ public:
gid_t sgid() const { return m_sgid; }
ProcessID ppid() const { return m_ppid; }
bool is_dumpable() const { return m_dumpable; }
void set_dumpable(bool dumpable) { m_dumpable = dumpable; }
ThreadID exec_tid() const { return m_exec_tid; }
mode_t umask() const { return m_umask; }
@ -371,6 +374,7 @@ public:
long sys$sysconf(int name);
int sys$disown(ProcessID);
void* sys$allocate_tls(size_t);
int sys$prctl(int option, FlatPtr arg1, FlatPtr arg2);
template<bool sockname, typename Params>
int get_sock_or_peer_name(const Params&);
@ -627,6 +631,8 @@ private:
ProcessID m_ppid { 0 };
mode_t m_umask { 022 };
bool m_dumpable { true };
Vector<gid_t> m_extra_gids;
WeakPtr<Region> m_master_tls_region;