From b818cf898e7953ee05cb8f80ec04f91d9279695c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 16 Jan 2021 22:27:38 +0100 Subject: Kernel+Userland: Remove sys$shbuf_allow_all() and userland wrappers Nobody is using globally shared shbufs anymore, so let's remove them. --- Kernel/API/Syscall.h | 1 - Kernel/Process.h | 1 - Kernel/SharedBuffer.cpp | 16 ---------------- Kernel/SharedBuffer.h | 2 -- Kernel/Syscalls/shbuf.cpp | 14 -------------- 5 files changed, 34 deletions(-) (limited to 'Kernel') diff --git a/Kernel/API/Syscall.h b/Kernel/API/Syscall.h index 18e227c001..8eb23a56d9 100644 --- a/Kernel/API/Syscall.h +++ b/Kernel/API/Syscall.h @@ -156,7 +156,6 @@ namespace Kernel { S(dbgputch) \ S(dbgputstr) \ S(watch_file) \ - S(shbuf_allow_all) \ S(mprotect) \ S(realpath) \ S(get_process_name) \ diff --git a/Kernel/Process.h b/Kernel/Process.h index 3d8bfba55b..fc80ca2ac9 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -336,7 +336,6 @@ public: int sys$mknod(Userspace); int sys$shbuf_create(int, void** buffer); int sys$shbuf_allow_pid(int, pid_t peer_pid); - int sys$shbuf_allow_all(int); void* sys$shbuf_get(int shbuf_id, Userspace size); int sys$shbuf_release(int shbuf_id); int sys$shbuf_seal(int shbuf_id); diff --git a/Kernel/SharedBuffer.cpp b/Kernel/SharedBuffer.cpp index 7ec25ea701..39bef11392 100644 --- a/Kernel/SharedBuffer.cpp +++ b/Kernel/SharedBuffer.cpp @@ -65,8 +65,6 @@ void SharedBuffer::sanity_check(const char* what) bool SharedBuffer::is_shared_with(ProcessID peer_pid) const { LOCKER(shared_buffers().lock(), Lock::Mode::Shared); - if (m_global) - return true; for (auto& ref : m_refs) { if (ref.pid == peer_pid) { return true; @@ -80,18 +78,6 @@ void* SharedBuffer::ref_for_process_and_get_address(Process& process) { LOCKER(shared_buffers().lock()); ASSERT(is_shared_with(process.pid())); - if (m_global) { - bool found = false; - for (auto& ref : m_refs) { - if (ref.pid == process.pid()) { - found = true; - break; - } - } - if (!found) - m_refs.append(Reference(process.pid())); - } - for (auto& ref : m_refs) { if (ref.pid == process.pid()) { if (!ref.region) { @@ -112,8 +98,6 @@ void* SharedBuffer::ref_for_process_and_get_address(Process& process) void SharedBuffer::share_with(ProcessID peer_pid) { LOCKER(shared_buffers().lock()); - if (m_global) - return; for (auto& ref : m_refs) { if (ref.pid == peer_pid) { // don't increment the reference count yet; let them shbuf_get it first. diff --git a/Kernel/SharedBuffer.h b/Kernel/SharedBuffer.h index 03cba038aa..f92f861fcd 100644 --- a/Kernel/SharedBuffer.h +++ b/Kernel/SharedBuffer.h @@ -65,7 +65,6 @@ public: bool is_shared_with(ProcessID peer_pid) const; void* ref_for_process_and_get_address(Process& process); void share_with(ProcessID peer_pid); - void share_globally() { m_global = true; } void deref_for_process(Process& process); bool disown(ProcessID pid); static void share_all_shared_buffers(Process& from_process, Process& with_process); @@ -86,7 +85,6 @@ public: private: int m_shbuf_id { -1 }; bool m_writable { true }; - bool m_global { false }; NonnullRefPtr m_vmobject; Vector m_refs; unsigned m_total_refs { 0 }; diff --git a/Kernel/Syscalls/shbuf.cpp b/Kernel/Syscalls/shbuf.cpp index c49674a876..6077905486 100644 --- a/Kernel/Syscalls/shbuf.cpp +++ b/Kernel/Syscalls/shbuf.cpp @@ -96,20 +96,6 @@ int Process::sys$shbuf_allow_pid(int shbuf_id, pid_t peer_pid) return 0; } -int Process::sys$shbuf_allow_all(int shbuf_id) -{ - REQUIRE_PROMISE(shared_buffer); - LOCKER(shared_buffers().lock()); - auto it = shared_buffers().resource().find(shbuf_id); - if (it == shared_buffers().resource().end()) - return -EINVAL; - auto& shared_buffer = *(*it).value; - if (!shared_buffer.is_shared_with(m_pid)) - return -EPERM; - shared_buffer.share_globally(); - return 0; -} - int Process::sys$shbuf_release(int shbuf_id) { REQUIRE_PROMISE(shared_buffer); -- cgit v1.2.3