From 05dbfe9ab60becc862fd8f51a8be85795df20c31 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 17 Jan 2021 00:18:01 +0100 Subject: [PATCH] Kernel: Remove sys$shbuf_seal() and userland wrappers There are no remaining users of this syscall so let it go. :^) --- AK/SharedBuffer.cpp | 11 ----------- AK/SharedBuffer.h | 1 - Kernel/API/Syscall.h | 1 - Kernel/Process.h | 1 - Kernel/SharedBuffer.cpp | 13 ------------- Kernel/SharedBuffer.h | 1 - Kernel/Syscalls/shbuf.cpp | 17 ----------------- .../DevTools/UserspaceEmulator/Emulator.cpp | 9 --------- Userland/DevTools/UserspaceEmulator/Emulator.h | 1 - .../UserspaceEmulator/SharedBufferRegion.cpp | 5 ----- .../UserspaceEmulator/SharedBufferRegion.h | 1 - Userland/Libraries/LibC/serenity.cpp | 6 ------ Userland/Libraries/LibC/serenity.h | 1 - 13 files changed, 68 deletions(-) diff --git a/AK/SharedBuffer.cpp b/AK/SharedBuffer.cpp index 873b3e4e339..3be2c2edd8a 100644 --- a/AK/SharedBuffer.cpp +++ b/AK/SharedBuffer.cpp @@ -165,15 +165,4 @@ SharedBuffer::~SharedBuffer() } } -void SharedBuffer::seal() -{ -#if defined(__serenity__) - int rc = shbuf_seal(m_shbuf_id); - if (rc < 0) { - perror("shbuf_seal"); - ASSERT_NOT_REACHED(); - } -#endif -} - } diff --git a/AK/SharedBuffer.h b/AK/SharedBuffer.h index a9cb438c701..da9c1be3dbe 100644 --- a/AK/SharedBuffer.h +++ b/AK/SharedBuffer.h @@ -39,7 +39,6 @@ public: bool share_with(pid_t); int shbuf_id() const { return m_shbuf_id; } - void seal(); int size() const { return m_size; } template diff --git a/Kernel/API/Syscall.h b/Kernel/API/Syscall.h index 8eb23a56d99..86a3439cf6a 100644 --- a/Kernel/API/Syscall.h +++ b/Kernel/API/Syscall.h @@ -129,7 +129,6 @@ namespace Kernel { S(chown) \ S(fchmod) \ S(symlink) \ - S(shbuf_seal) \ S(sendmsg) \ S(recvmsg) \ S(getsockopt) \ diff --git a/Kernel/Process.h b/Kernel/Process.h index fc80ca2ac90..0f46ca10357 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -338,7 +338,6 @@ public: int sys$shbuf_allow_pid(int, pid_t peer_pid); void* sys$shbuf_get(int shbuf_id, Userspace size); int sys$shbuf_release(int shbuf_id); - int sys$shbuf_seal(int shbuf_id); int sys$halt(); int sys$reboot(); int sys$realpath(Userspace); diff --git a/Kernel/SharedBuffer.cpp b/Kernel/SharedBuffer.cpp index e4e082d3c50..caa32d2a43c 100644 --- a/Kernel/SharedBuffer.cpp +++ b/Kernel/SharedBuffer.cpp @@ -185,17 +185,4 @@ void SharedBuffer::destroy_if_unused() } } -void SharedBuffer::seal() -{ - LOCKER(shared_buffers().lock()); - m_writable = false; - for (auto& ref : m_refs) { - // TODO: Region needs to be RefCounted! - if (auto* region = ref.region.unsafe_ptr()) { - region->set_writable(false); - region->remap(); - } - } -} - } diff --git a/Kernel/SharedBuffer.h b/Kernel/SharedBuffer.h index 6fa8b7e2b27..4943a60d068 100644 --- a/Kernel/SharedBuffer.h +++ b/Kernel/SharedBuffer.h @@ -70,7 +70,6 @@ public: static void share_all_shared_buffers(Process& from_process, Process& with_process); size_t size() const { return m_vmobject->size(); } void destroy_if_unused(); - void seal(); AnonymousVMObject& vmobject() { return m_vmobject; } const AnonymousVMObject& vmobject() const { return m_vmobject; } int id() const { return m_shbuf_id; } diff --git a/Kernel/Syscalls/shbuf.cpp b/Kernel/Syscalls/shbuf.cpp index 60779054864..7b885cd9f2c 100644 --- a/Kernel/Syscalls/shbuf.cpp +++ b/Kernel/Syscalls/shbuf.cpp @@ -134,21 +134,4 @@ void* Process::sys$shbuf_get(int shbuf_id, Userspace user_size) return shared_buffer.ref_for_process_and_get_address(*this); } -int Process::sys$shbuf_seal(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; -#ifdef SHARED_BUFFER_DEBUG - klog() << "Sealing shared buffer " << shbuf_id; -#endif - shared_buffer.seal(); - return 0; -} - } diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp index fa86c264173..b4a42a4320d 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp @@ -393,8 +393,6 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3) return virt$shbuf_get(arg1, arg2); case SC_shbuf_release: return virt$shbuf_release(arg1); - case SC_shbuf_seal: - return virt$shbuf_seal(arg1); case SC_profiling_enable: return virt$profiling_enable(arg1); case SC_profiling_disable: @@ -604,13 +602,6 @@ int Emulator::virt$shbuf_release(int shbuf_id) return rc; } -int Emulator::virt$shbuf_seal(int shbuf_id) -{ - auto* region = m_mmu.shbuf_region(shbuf_id); - ASSERT(region); - return region->seal(); -} - int Emulator::virt$profiling_enable(pid_t pid) { return syscall(SC_profiling_enable, pid); diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.h b/Userland/DevTools/UserspaceEmulator/Emulator.h index db3dd39cd16..dae845187fb 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.h +++ b/Userland/DevTools/UserspaceEmulator/Emulator.h @@ -95,7 +95,6 @@ private: int virt$shbuf_allow_pid(int, pid_t peer_pid); FlatPtr virt$shbuf_get(int shbuf_id, FlatPtr size); int virt$shbuf_release(int shbuf_id); - int virt$shbuf_seal(int shbuf_id); int virt$profiling_enable(pid_t); int virt$profiling_disable(pid_t); int virt$disown(pid_t); diff --git a/Userland/DevTools/UserspaceEmulator/SharedBufferRegion.cpp b/Userland/DevTools/UserspaceEmulator/SharedBufferRegion.cpp index a4c58e862a5..537200c2b3c 100644 --- a/Userland/DevTools/UserspaceEmulator/SharedBufferRegion.cpp +++ b/Userland/DevTools/UserspaceEmulator/SharedBufferRegion.cpp @@ -109,11 +109,6 @@ int SharedBufferRegion::allow_pid(pid_t pid) return syscall(SC_shbuf_allow_pid, m_shbuf_id, pid); } -int SharedBufferRegion::seal() -{ - return syscall(SC_shbuf_seal, m_shbuf_id); -} - int SharedBufferRegion::release() { return syscall(SC_shbuf_release, m_shbuf_id); diff --git a/Userland/DevTools/UserspaceEmulator/SharedBufferRegion.h b/Userland/DevTools/UserspaceEmulator/SharedBufferRegion.h index c3e0df87f90..58636f26433 100644 --- a/Userland/DevTools/UserspaceEmulator/SharedBufferRegion.h +++ b/Userland/DevTools/UserspaceEmulator/SharedBufferRegion.h @@ -52,7 +52,6 @@ public: int shbuf_id() const { return m_shbuf_id; } int allow_pid(pid_t); - int seal(); int release(); private: diff --git a/Userland/Libraries/LibC/serenity.cpp b/Userland/Libraries/LibC/serenity.cpp index 730f37932a1..eb25403262e 100644 --- a/Userland/Libraries/LibC/serenity.cpp +++ b/Userland/Libraries/LibC/serenity.cpp @@ -95,12 +95,6 @@ int shbuf_release(int shbuf_id) __RETURN_WITH_ERRNO(rc, rc, -1); } -int shbuf_seal(int shbuf_id) -{ - int rc = syscall(SC_shbuf_seal, shbuf_id); - __RETURN_WITH_ERRNO(rc, rc, -1); -} - int shbuf_create(int size, void** buffer) { int rc = syscall(SC_shbuf_create, size, buffer); diff --git a/Userland/Libraries/LibC/serenity.h b/Userland/Libraries/LibC/serenity.h index f1abc160bda..b3e8e7f3c2d 100644 --- a/Userland/Libraries/LibC/serenity.h +++ b/Userland/Libraries/LibC/serenity.h @@ -37,7 +37,6 @@ int shbuf_create(int, void** buffer); int shbuf_allow_pid(int, pid_t peer_pid); void* shbuf_get(int shbuf_id, size_t* size); int shbuf_release(int shbuf_id); -int shbuf_seal(int shbuf_id); int module_load(const char* path, size_t path_length); int module_unload(const char* name, size_t name_length);