summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@serenityos.org>2020-05-15 12:05:44 +0300
committerAndreas Kling <kling@serenityos.org>2020-05-15 11:43:58 +0200
commit752617cbb2021aa52a9b822f7df17464a5f38fa5 (patch)
tree3a928ccc99a3a72fdd151620f9263da1ca539254 /Kernel
parent00c166e2cab6e0a7c00e8d863082084d249b9a43 (diff)
downloadserenity-752617cbb2021aa52a9b822f7df17464a5f38fa5.zip
Kernel: Disallow opening socket files
You can still open files that have sockets attached to them from inside the kernel via VFS::open() (and in fact, that is what LocalSocket itslef uses), but trying to do that from userspace using open() will now fail with ENXIO.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Process.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 38cd9237c2..b5cbae8776 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -2082,6 +2082,10 @@ int Process::sys$open(const Syscall::SC_open_params* user_params)
if (result.is_error())
return result.error();
auto description = result.value();
+
+ if (description->inode() && description->inode()->socket())
+ return -ENXIO;
+
u32 fd_flags = (options & O_CLOEXEC) ? FD_CLOEXEC : 0;
m_fds[fd].set(move(description), fd_flags);
return fd;