mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 18:25:08 +00:00
Kernel+Userland: Remove sys$shbuf_allow_all() and userland wrappers
Nobody is using globally shared shbufs anymore, so let's remove them.
This commit is contained in:
parent
968c1fa00a
commit
b818cf898e
13 changed files with 0 additions and 70 deletions
|
@ -98,18 +98,6 @@ bool SharedBuffer::share_with([[maybe_unused]] pid_t peer)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SharedBuffer::share_globally()
|
|
||||||
{
|
|
||||||
#if defined(__serenity__)
|
|
||||||
int ret = shbuf_allow_all(shbuf_id());
|
|
||||||
if (ret < 0) {
|
|
||||||
perror("shbuf_allow_all");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<SharedBuffer> SharedBuffer::create_from_shbuf_id(int shbuf_id)
|
RefPtr<SharedBuffer> SharedBuffer::create_from_shbuf_id(int shbuf_id)
|
||||||
{
|
{
|
||||||
#if defined(__serenity__)
|
#if defined(__serenity__)
|
||||||
|
|
|
@ -37,7 +37,6 @@ public:
|
||||||
static RefPtr<SharedBuffer> create_from_shbuf_id(int);
|
static RefPtr<SharedBuffer> create_from_shbuf_id(int);
|
||||||
~SharedBuffer();
|
~SharedBuffer();
|
||||||
|
|
||||||
bool share_globally();
|
|
||||||
bool share_with(pid_t);
|
bool share_with(pid_t);
|
||||||
int shbuf_id() const { return m_shbuf_id; }
|
int shbuf_id() const { return m_shbuf_id; }
|
||||||
void seal();
|
void seal();
|
||||||
|
|
|
@ -156,7 +156,6 @@ namespace Kernel {
|
||||||
S(dbgputch) \
|
S(dbgputch) \
|
||||||
S(dbgputstr) \
|
S(dbgputstr) \
|
||||||
S(watch_file) \
|
S(watch_file) \
|
||||||
S(shbuf_allow_all) \
|
|
||||||
S(mprotect) \
|
S(mprotect) \
|
||||||
S(realpath) \
|
S(realpath) \
|
||||||
S(get_process_name) \
|
S(get_process_name) \
|
||||||
|
|
|
@ -336,7 +336,6 @@ public:
|
||||||
int sys$mknod(Userspace<const Syscall::SC_mknod_params*>);
|
int sys$mknod(Userspace<const Syscall::SC_mknod_params*>);
|
||||||
int sys$shbuf_create(int, void** buffer);
|
int sys$shbuf_create(int, void** buffer);
|
||||||
int sys$shbuf_allow_pid(int, pid_t peer_pid);
|
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_t*> size);
|
void* sys$shbuf_get(int shbuf_id, Userspace<size_t*> size);
|
||||||
int sys$shbuf_release(int shbuf_id);
|
int sys$shbuf_release(int shbuf_id);
|
||||||
int sys$shbuf_seal(int shbuf_id);
|
int sys$shbuf_seal(int shbuf_id);
|
||||||
|
|
|
@ -65,8 +65,6 @@ void SharedBuffer::sanity_check(const char* what)
|
||||||
bool SharedBuffer::is_shared_with(ProcessID peer_pid) const
|
bool SharedBuffer::is_shared_with(ProcessID peer_pid) const
|
||||||
{
|
{
|
||||||
LOCKER(shared_buffers().lock(), Lock::Mode::Shared);
|
LOCKER(shared_buffers().lock(), Lock::Mode::Shared);
|
||||||
if (m_global)
|
|
||||||
return true;
|
|
||||||
for (auto& ref : m_refs) {
|
for (auto& ref : m_refs) {
|
||||||
if (ref.pid == peer_pid) {
|
if (ref.pid == peer_pid) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -80,18 +78,6 @@ void* SharedBuffer::ref_for_process_and_get_address(Process& process)
|
||||||
{
|
{
|
||||||
LOCKER(shared_buffers().lock());
|
LOCKER(shared_buffers().lock());
|
||||||
ASSERT(is_shared_with(process.pid()));
|
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) {
|
for (auto& ref : m_refs) {
|
||||||
if (ref.pid == process.pid()) {
|
if (ref.pid == process.pid()) {
|
||||||
if (!ref.region) {
|
if (!ref.region) {
|
||||||
|
@ -112,8 +98,6 @@ void* SharedBuffer::ref_for_process_and_get_address(Process& process)
|
||||||
void SharedBuffer::share_with(ProcessID peer_pid)
|
void SharedBuffer::share_with(ProcessID peer_pid)
|
||||||
{
|
{
|
||||||
LOCKER(shared_buffers().lock());
|
LOCKER(shared_buffers().lock());
|
||||||
if (m_global)
|
|
||||||
return;
|
|
||||||
for (auto& ref : m_refs) {
|
for (auto& ref : m_refs) {
|
||||||
if (ref.pid == peer_pid) {
|
if (ref.pid == peer_pid) {
|
||||||
// don't increment the reference count yet; let them shbuf_get it first.
|
// don't increment the reference count yet; let them shbuf_get it first.
|
||||||
|
|
|
@ -65,7 +65,6 @@ public:
|
||||||
bool is_shared_with(ProcessID peer_pid) const;
|
bool is_shared_with(ProcessID peer_pid) const;
|
||||||
void* ref_for_process_and_get_address(Process& process);
|
void* ref_for_process_and_get_address(Process& process);
|
||||||
void share_with(ProcessID peer_pid);
|
void share_with(ProcessID peer_pid);
|
||||||
void share_globally() { m_global = true; }
|
|
||||||
void deref_for_process(Process& process);
|
void deref_for_process(Process& process);
|
||||||
bool disown(ProcessID pid);
|
bool disown(ProcessID pid);
|
||||||
static void share_all_shared_buffers(Process& from_process, Process& with_process);
|
static void share_all_shared_buffers(Process& from_process, Process& with_process);
|
||||||
|
@ -86,7 +85,6 @@ public:
|
||||||
private:
|
private:
|
||||||
int m_shbuf_id { -1 };
|
int m_shbuf_id { -1 };
|
||||||
bool m_writable { true };
|
bool m_writable { true };
|
||||||
bool m_global { false };
|
|
||||||
NonnullRefPtr<AnonymousVMObject> m_vmobject;
|
NonnullRefPtr<AnonymousVMObject> m_vmobject;
|
||||||
Vector<Reference, 2> m_refs;
|
Vector<Reference, 2> m_refs;
|
||||||
unsigned m_total_refs { 0 };
|
unsigned m_total_refs { 0 };
|
||||||
|
|
|
@ -96,20 +96,6 @@ int Process::sys$shbuf_allow_pid(int shbuf_id, pid_t peer_pid)
|
||||||
return 0;
|
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)
|
int Process::sys$shbuf_release(int shbuf_id)
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(shared_buffer);
|
REQUIRE_PROMISE(shared_buffer);
|
||||||
|
|
|
@ -389,8 +389,6 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
|
||||||
return virt$shbuf_create(arg1, arg2);
|
return virt$shbuf_create(arg1, arg2);
|
||||||
case SC_shbuf_allow_pid:
|
case SC_shbuf_allow_pid:
|
||||||
return virt$shbuf_allow_pid(arg1, arg2);
|
return virt$shbuf_allow_pid(arg1, arg2);
|
||||||
case SC_shbuf_allow_all:
|
|
||||||
return virt$shbuf_allow_all(arg1);
|
|
||||||
case SC_shbuf_get:
|
case SC_shbuf_get:
|
||||||
return virt$shbuf_get(arg1, arg2);
|
return virt$shbuf_get(arg1, arg2);
|
||||||
case SC_shbuf_release:
|
case SC_shbuf_release:
|
||||||
|
@ -597,13 +595,6 @@ int Emulator::virt$shbuf_allow_pid(int shbuf_id, pid_t peer_pid)
|
||||||
return region->allow_pid(peer_pid);
|
return region->allow_pid(peer_pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Emulator::virt$shbuf_allow_all(int shbuf_id)
|
|
||||||
{
|
|
||||||
auto* region = m_mmu.shbuf_region(shbuf_id);
|
|
||||||
ASSERT(region);
|
|
||||||
return region->allow_all();
|
|
||||||
}
|
|
||||||
|
|
||||||
int Emulator::virt$shbuf_release(int shbuf_id)
|
int Emulator::virt$shbuf_release(int shbuf_id)
|
||||||
{
|
{
|
||||||
auto* region = m_mmu.shbuf_region(shbuf_id);
|
auto* region = m_mmu.shbuf_region(shbuf_id);
|
||||||
|
|
|
@ -93,7 +93,6 @@ private:
|
||||||
int virt$gethostname(FlatPtr, ssize_t);
|
int virt$gethostname(FlatPtr, ssize_t);
|
||||||
int virt$shbuf_create(int size, FlatPtr buffer);
|
int virt$shbuf_create(int size, FlatPtr buffer);
|
||||||
int virt$shbuf_allow_pid(int, pid_t peer_pid);
|
int virt$shbuf_allow_pid(int, pid_t peer_pid);
|
||||||
int virt$shbuf_allow_all(int);
|
|
||||||
FlatPtr virt$shbuf_get(int shbuf_id, FlatPtr size);
|
FlatPtr virt$shbuf_get(int shbuf_id, FlatPtr size);
|
||||||
int virt$shbuf_release(int shbuf_id);
|
int virt$shbuf_release(int shbuf_id);
|
||||||
int virt$shbuf_seal(int shbuf_id);
|
int virt$shbuf_seal(int shbuf_id);
|
||||||
|
|
|
@ -104,11 +104,6 @@ void SharedBufferRegion::write64(u32 offset, ValueWithShadow<u64> value)
|
||||||
*reinterpret_cast<u64*>(m_shadow_data + offset) = value.shadow();
|
*reinterpret_cast<u64*>(m_shadow_data + offset) = value.shadow();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SharedBufferRegion::allow_all()
|
|
||||||
{
|
|
||||||
return syscall(SC_shbuf_allow_all, m_shbuf_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
int SharedBufferRegion::allow_pid(pid_t pid)
|
int SharedBufferRegion::allow_pid(pid_t pid)
|
||||||
{
|
{
|
||||||
return syscall(SC_shbuf_allow_pid, m_shbuf_id, pid);
|
return syscall(SC_shbuf_allow_pid, m_shbuf_id, pid);
|
||||||
|
|
|
@ -51,7 +51,6 @@ public:
|
||||||
|
|
||||||
int shbuf_id() const { return m_shbuf_id; }
|
int shbuf_id() const { return m_shbuf_id; }
|
||||||
|
|
||||||
int allow_all();
|
|
||||||
int allow_pid(pid_t);
|
int allow_pid(pid_t);
|
||||||
int seal();
|
int seal();
|
||||||
int release();
|
int release();
|
||||||
|
|
|
@ -113,12 +113,6 @@ int shbuf_allow_pid(int shbuf_id, pid_t peer_pid)
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int shbuf_allow_all(int shbuf_id)
|
|
||||||
{
|
|
||||||
int rc = syscall(SC_shbuf_allow_all, shbuf_id);
|
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int get_stack_bounds(uintptr_t* user_stack_base, size_t* user_stack_size)
|
int get_stack_bounds(uintptr_t* user_stack_base, size_t* user_stack_size)
|
||||||
{
|
{
|
||||||
int rc = syscall(SC_get_stack_bounds, user_stack_base, user_stack_size);
|
int rc = syscall(SC_get_stack_bounds, user_stack_base, user_stack_size);
|
||||||
|
|
|
@ -35,7 +35,6 @@ int disown(pid_t);
|
||||||
|
|
||||||
int shbuf_create(int, void** buffer);
|
int shbuf_create(int, void** buffer);
|
||||||
int shbuf_allow_pid(int, pid_t peer_pid);
|
int shbuf_allow_pid(int, pid_t peer_pid);
|
||||||
int shbuf_allow_all(int);
|
|
||||||
void* shbuf_get(int shbuf_id, size_t* size);
|
void* shbuf_get(int shbuf_id, size_t* size);
|
||||||
int shbuf_release(int shbuf_id);
|
int shbuf_release(int shbuf_id);
|
||||||
int shbuf_seal(int shbuf_id);
|
int shbuf_seal(int shbuf_id);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue