From c32176db278ccb491475840c46fbdb9fdd21f4ee Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 23 Jan 2021 15:35:20 +0100 Subject: 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. --- Kernel/Net/LocalSocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Kernel/Net/LocalSocket.cpp') 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 user_address, socklen_t add dbgln("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; } -- cgit v1.2.3