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.
This commit is contained in:
Bananymous 2023-11-18 14:26:44 +02:00
parent 6e2443ca72
commit 5293ae070d
2 changed files with 8 additions and 2 deletions

View File

@ -13,6 +13,9 @@ namespace Kernel
static BAN::ErrorOr<BAN::RefPtr<ProcPidInode>> 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<BAN::RefPtr<ProcROInode>> 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<size_t> read_impl(off_t, BAN::ByteSpan) override;

View File

@ -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; }