From 0620ed3d4f05a58e0de341962d744fa3b57250f7 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 17 Sep 2024 19:11:48 +0300 Subject: [PATCH] Kernel: Fix file open permissions for some syscalls --- kernel/kernel/Process.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index 2f71f9f5ba..9e61f08907 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -1051,7 +1051,7 @@ namespace Kernel LockGuard _(m_process_lock); - auto inode = TRY(find_file(fd, path, O_SEARCH | flag)).inode; + auto inode = TRY(find_file(fd, path, flag)).inode; if (!m_credentials.is_superuser() && inode->uid() != m_credentials.euid()) { @@ -1073,7 +1073,7 @@ namespace Kernel LockGuard _(m_process_lock); - auto inode = TRY(find_file(fd, path, O_SEARCH | flag)).inode; + auto inode = TRY(find_file(fd, path, flag)).inode; if (uid != -1 && !m_credentials.is_superuser()) return BAN::Error::from_errno(EPERM); @@ -1425,7 +1425,7 @@ namespace Kernel LockGuard _(m_process_lock); TRY(validate_pointer_access(buf, sizeof(struct stat), true)); - auto inode = TRY(find_file(fd, path, O_SEARCH | flag)).inode; + auto inode = TRY(find_file(fd, path, flag)).inode; buf->st_dev = inode->dev(); buf->st_ino = inode->ino(); buf->st_mode = inode->mode().mode; @@ -1451,7 +1451,7 @@ namespace Kernel auto absolute_path = TRY(absolute_path_of(path)); - auto file = TRY(VirtualFileSystem::get().file_from_absolute_path(m_credentials, absolute_path, O_SEARCH)); + auto file = TRY(VirtualFileSystem::get().file_from_absolute_path(m_credentials, absolute_path, O_RDONLY)); if (file.canonical_path.size() >= PATH_MAX) return BAN::Error::from_errno(ENAMETOOLONG);