diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-26 15:51:57 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-26 15:51:57 +0200 |
commit | fb826aa59abd6e2baff6a8ebe1c749d1ddc04731 (patch) | |
tree | 49503477a3d357cf1c351f9daa84c1c0b592659e /Kernel | |
parent | f897c410927817050c9f98081d45a32e893e6d73 (diff) | |
download | serenity-fb826aa59abd6e2baff6a8ebe1c749d1ddc04731.zip |
Kernel: Make sys$sethostname() superuser-only
Also take the hostname string lock exclusively.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Process.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index c81e9598ed..1ee32709f8 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -715,9 +715,11 @@ int Process::sys$gethostname(char* buffer, ssize_t size) int Process::sys$sethostname(const char* hostname, ssize_t length) { REQUIRE_PROMISE(stdio); + if (!is_superuser()) + return -EPERM; if (length < 0) return -EINVAL; - LOCKER(*s_hostname_lock, Lock::Mode::Shared); + LOCKER(*s_hostname_lock, Lock::Mode::Exclusive); if (length > 64) return -ENAMETOOLONG; *s_hostname = validate_and_copy_string_from_user(hostname, length); |