From cadb56d8ba974cdc8462b74f1b7d3e09a8dab3af Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sat, 18 Nov 2023 14:26:44 +0200 Subject: [PATCH] Kernel: ProcFS inodes reflect processes ruid/rgid setgid/setuid did not change the permissions of procfs inodes. This made Shell launched by init not appear in meminfo. --- kernel/include/kernel/FS/ProcFS/Inode.h | 6 ++++++ kernel/include/kernel/FS/TmpFS/Inode.h | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/include/kernel/FS/ProcFS/Inode.h b/kernel/include/kernel/FS/ProcFS/Inode.h index 79f4a309af..93b7411615 100644 --- a/kernel/include/kernel/FS/ProcFS/Inode.h +++ b/kernel/include/kernel/FS/ProcFS/Inode.h @@ -13,6 +13,9 @@ namespace Kernel static BAN::ErrorOr> create_new(Process&, TmpFileSystem&, mode_t, uid_t, gid_t); ~ProcPidInode() = default; + virtual uid_t uid() const override { return m_process.credentials().ruid(); } + virtual gid_t gid() const override { return m_process.credentials().rgid(); } + void cleanup(); protected: @@ -31,6 +34,9 @@ namespace Kernel static BAN::ErrorOr> create_new(Process&, size_t (Process::*callback)(off_t, BAN::ByteSpan) const, TmpFileSystem&, mode_t, uid_t, gid_t); ~ProcROInode() = default; + virtual uid_t uid() const override { return m_process.credentials().ruid(); } + virtual gid_t gid() const override { return m_process.credentials().rgid(); } + protected: virtual BAN::ErrorOr read_impl(off_t, BAN::ByteSpan) override; diff --git a/kernel/include/kernel/FS/TmpFS/Inode.h b/kernel/include/kernel/FS/TmpFS/Inode.h index e567aa27ee..b9a202efe0 100644 --- a/kernel/include/kernel/FS/TmpFS/Inode.h +++ b/kernel/include/kernel/FS/TmpFS/Inode.h @@ -27,8 +27,8 @@ namespace Kernel virtual ino_t ino() const override final { return m_ino; } virtual Mode mode() const override final { return Mode(m_inode_info.mode); } virtual nlink_t nlink() const override final { return m_inode_info.nlink; } - virtual uid_t uid() const override final { return m_inode_info.uid; } - virtual gid_t gid() const override final { return m_inode_info.gid; } + virtual uid_t uid() const override { return m_inode_info.uid; } + virtual gid_t gid() const override { return m_inode_info.gid; } virtual off_t size() const override final { return m_inode_info.size; } virtual timespec atime() const override final { return m_inode_info.atime; } virtual timespec mtime() const override final { return m_inode_info.mtime; }