summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/getuid.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-03-11 13:13:05 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-11 14:21:49 +0100
commit90c0f9664ea96d3d4c23eaba8a431f6e57db9e6c (patch)
treea9799a005e26b6d4c94083bd75f23b3b723076c4 /Kernel/Syscalls/getuid.cpp
parent4fcc637e29104f543c1bf278cc2481bfeb9ea3fa (diff)
downloadserenity-90c0f9664ea96d3d4c23eaba8a431f6e57db9e6c.zip
Kernel: Don't keep protected Process data in a separate allocation
The previous architecture had a huge flaw: the pointer to the protected data was itself unprotected, allowing you to overwrite it at any time. This patch reorganizes the protected data so it's part of the Process class itself. (Actually, it's a new ProcessBase helper class.) We use the first 4 KB of Process objects themselves as the new storage location for protected data. Then we make Process objects page-aligned using MAKE_ALIGNED_ALLOCATED. This allows us to easily turn on/off write-protection for everything in the ProcessBase portion of Process. :^) Thanks to @bugaevc for pointing out the flaw! This is still not perfect but it's an improvement.
Diffstat (limited to 'Kernel/Syscalls/getuid.cpp')
-rw-r--r--Kernel/Syscalls/getuid.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Kernel/Syscalls/getuid.cpp b/Kernel/Syscalls/getuid.cpp
index f77c4f9c00..66e60cbc6c 100644
--- a/Kernel/Syscalls/getuid.cpp
+++ b/Kernel/Syscalls/getuid.cpp
@@ -55,7 +55,7 @@ KResultOr<gid_t> Process::sys$getegid()
KResultOr<int> Process::sys$getresuid(Userspace<uid_t*> ruid, Userspace<uid_t*> euid, Userspace<uid_t*> suid)
{
REQUIRE_PROMISE(stdio);
- if (!copy_to_user(ruid, &protected_data().uid) || !copy_to_user(euid, &protected_data().euid) || !copy_to_user(suid, &protected_data().suid))
+ if (!copy_to_user(ruid, &m_uid) || !copy_to_user(euid, &m_euid) || !copy_to_user(suid, &m_suid))
return EFAULT;
return 0;
}
@@ -63,7 +63,7 @@ KResultOr<int> Process::sys$getresuid(Userspace<uid_t*> ruid, Userspace<uid_t*>
KResultOr<int> Process::sys$getresgid(Userspace<gid_t*> rgid, Userspace<gid_t*> egid, Userspace<gid_t*> sgid)
{
REQUIRE_PROMISE(stdio);
- if (!copy_to_user(rgid, &protected_data().gid) || !copy_to_user(egid, &protected_data().egid) || !copy_to_user(sgid, &protected_data().sgid))
+ if (!copy_to_user(rgid, &m_gid) || !copy_to_user(egid, &m_egid) || !copy_to_user(sgid, &m_sgid))
return EFAULT;
return 0;
}