1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

Kernel: Make Process creation APIs OOM safe

This change looks more involved than it actually is. This simply
reshuffles the previous Process constructor and splits out the
parts which can fail (resource allocation) into separate methods
which can be called from a factory method. The factory is then
used everywhere instead of the constructor.
This commit is contained in:
Brian Gianforcaro 2021-05-14 04:55:43 -07:00 committed by Andreas Kling
parent 77868abe6a
commit ede1483e48
3 changed files with 30 additions and 8 deletions

View file

@ -499,7 +499,9 @@ private:
bool add_thread(Thread&);
bool remove_thread(Thread&);
Process(RefPtr<Thread>& first_thread, const String& name, uid_t, gid_t, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> cwd = nullptr, RefPtr<Custody> executable = nullptr, TTY* = nullptr, Process* fork_parent = nullptr);
Process(const String& name, uid_t uid, gid_t gid, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> cwd, RefPtr<Custody> executable, TTY* tty);
static RefPtr<Process> create(RefPtr<Thread>& first_thread, const String& name, uid_t, gid_t, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> cwd = nullptr, RefPtr<Custody> executable = nullptr, TTY* = nullptr, Process* fork_parent = nullptr);
KResult attach_resources(RefPtr<Thread>& first_thread, Process* fork_parent);
static ProcessID allocate_pid();
void kill_threads_except_self();