From 489e451ccef8c74f521fe1bb84c9f55b11aadd66 Mon Sep 17 00:00:00 2001 From: Drew Stratford Date: Fri, 25 Oct 2019 02:46:31 +1300 Subject: [PATCH] Kernel: Return error when attempting to read from a directory. We now return EISDIR whenever a program attempts to call sys$read on a directory. Previously, attempting to read a directory could either return junk data or, in the case of /proc/, cause a kernel panic. --- Kernel/Process.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 9887772a10..13157de840 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1128,6 +1128,8 @@ ssize_t Process::sys$read(int fd, u8* buffer, ssize_t size) auto* description = file_description(fd); if (!description) return -EBADF; + if (description->is_directory()) + return -EISDIR; if (description->is_blocking()) { if (!description->can_read()) { if (current->block(*description) == Thread::BlockResult::InterruptedBySignal)