diff options
author | Andreas Kling <kling@serenityos.org> | 2022-08-21 12:18:26 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-08-21 12:25:14 +0200 |
commit | 8ed06ad814734430193f3673b5e00861eda9aa47 (patch) | |
tree | 1a21a6c5ba65c1de3e9446eb091ec82b922f3780 /Kernel/Syscalls/setpgid.cpp | |
parent | 728c3fbd14252bd746f97dbb5441063992074b6b (diff) | |
download | serenity-8ed06ad814734430193f3673b5e00861eda9aa47.zip |
Kernel: Guard Process "protected data" with a spinlock
This ensures that both mutable and immutable access to the protected
data of a process is serialized.
Note that there may still be multiple TOCTOU issues around this, as we
have a bunch of convenience accessors that make it easy to introduce
them. We'll need to audit those as well.
Diffstat (limited to 'Kernel/Syscalls/setpgid.cpp')
-rw-r--r-- | Kernel/Syscalls/setpgid.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Kernel/Syscalls/setpgid.cpp b/Kernel/Syscalls/setpgid.cpp index 92dbc681ba..b6473484e7 100644 --- a/Kernel/Syscalls/setpgid.cpp +++ b/Kernel/Syscalls/setpgid.cpp @@ -40,9 +40,10 @@ ErrorOr<FlatPtr> Process::sys$setsid() m_pg = TRY(ProcessGroup::try_create(ProcessGroupID(pid().value()))); m_tty = nullptr; - ProtectedDataMutationScope scope { *this }; - m_protected_values.sid = pid().value(); - return sid().value(); + return with_mutable_protected_data([&](auto& protected_data) -> ErrorOr<FlatPtr> { + protected_data.sid = pid().value(); + return protected_data.sid.value(); + }); } ErrorOr<FlatPtr> Process::sys$getpgid(pid_t pid) |