From 27bfb01f251c0218bffba1555d75bb4e13949852 Mon Sep 17 00:00:00 2001 From: Spencer Dixon Date: Sun, 2 May 2021 12:56:59 -0400 Subject: [PATCH] Kernel: Fix ProcFS for non-process backed sub dirs While hacking on `sysctl` an issue in ProcFS was making me unable to read/write from `/proc/sys/XXX`. Some directories in the ProcFS are not actually backed by a process and need to return `nullptr` so callbacks get properly set. We now do an explicit check for the parent to ensure it's one that is PID-based. --- Kernel/FileSystem/ProcFS.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 9abde39287..d8663de71e 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -1045,7 +1045,11 @@ ProcFSInode::~ProcFSInode() RefPtr ProcFSInode::process() const { - return Process::from_pid(to_pid(identifier())); + auto parent = to_proc_parent_directory(identifier()); + if (parent == PDI_PID || parent == PDI_PID_fd || parent == PDI_PID_stacks) + return Process::from_pid(to_pid(identifier())); + + return nullptr; } KResult ProcFSInode::refresh_data(FileDescription& description) const