diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-23 15:35:20 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-23 16:45:05 +0100 |
commit | c32176db278ccb491475840c46fbdb9fdd21f4ee (patch) | |
tree | dce35b83aa87e8f41a543075223f93ad2278af43 | |
parent | f2ea6c3d4c32c0a6ed160980bf19219d64ddccab (diff) | |
download | serenity-c32176db278ccb491475840c46fbdb9fdd21f4ee.zip |
Kernel: Don't preserve set-uid bit in open() and bind() modes
For some reason we were keeping the bits 04777 in file modes. That
doesn't seem right and I can't think of a reason why the set-uid bit
should be allowed to slip through.
-rw-r--r-- | Kernel/Net/LocalSocket.cpp | 4 | ||||
-rw-r--r-- | Kernel/Syscalls/open.cpp | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index 4ad67b810c..0b3ffd9cb6 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -114,7 +114,7 @@ KResult LocalSocket::bind(Userspace<const sockaddr*> user_address, socklen_t add dbgln<debug_local_socket>("LocalSocket({}) bind({})", this, path); - mode_t mode = S_IFSOCK | (m_prebind_mode & 04777); + mode_t mode = S_IFSOCK | (m_prebind_mode & 0777); UidAndGid owner { m_prebind_uid, m_prebind_gid }; auto result = VFS::the().open(path, O_CREAT | O_EXCL | O_NOFOLLOW_NOERROR, mode, Process::current()->current_directory(), owner); if (result.is_error()) { @@ -411,7 +411,7 @@ KResult LocalSocket::chmod(FileDescription&, mode_t mode) if (m_file) return m_file->chmod(mode); - m_prebind_mode = mode & 04777; + m_prebind_mode = mode & 0777; return KSuccess; } diff --git a/Kernel/Syscalls/open.cpp b/Kernel/Syscalls/open.cpp index 8da12548a6..ebbe7f950a 100644 --- a/Kernel/Syscalls/open.cpp +++ b/Kernel/Syscalls/open.cpp @@ -57,7 +57,7 @@ int Process::sys$open(Userspace<const Syscall::SC_open_params*> user_params) REQUIRE_PROMISE(cpath); // Ignore everything except permission bits. - mode &= 04777; + mode &= 0777; auto path = get_syscall_path_argument(params.path); if (path.is_error()) |