diff options
author | Andreas Kling <kling@serenityos.org> | 2021-03-01 15:53:33 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-01 15:53:33 +0100 |
commit | 272c2e6ec54c6e013c971214f59046f3e27ea55a (patch) | |
tree | 54b1a03cc54ee6d666faa9024ef3065884c3553b | |
parent | bebceaa32ce53ad7042673ce01f497da0d3bade4 (diff) | |
download | serenity-272c2e6ec54c6e013c971214f59046f3e27ea55a.zip |
Kernel: Use Userspace<T> in sys${munmap,mprotect,madvise,msyscall}()
-rw-r--r-- | Kernel/Process.h | 8 | ||||
-rw-r--r-- | Kernel/Syscalls/mmap.cpp | 16 |
2 files changed, 12 insertions, 12 deletions
diff --git a/Kernel/Process.h b/Kernel/Process.h index 68dc13539d..31aba2b744 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -253,11 +253,11 @@ public: KResultOr<pid_t> sys$waitid(Userspace<const Syscall::SC_waitid_params*>); KResultOr<FlatPtr> sys$mmap(Userspace<const Syscall::SC_mmap_params*>); KResultOr<FlatPtr> sys$mremap(Userspace<const Syscall::SC_mremap_params*>); - KResultOr<int> sys$munmap(void*, size_t size); + KResultOr<int> sys$munmap(Userspace<void*>, size_t); KResultOr<int> sys$set_mmap_name(Userspace<const Syscall::SC_set_mmap_name_params*>); - KResultOr<int> sys$mprotect(void*, size_t, int prot); - KResultOr<int> sys$madvise(void*, size_t, int advice); - KResultOr<int> sys$msyscall(void*); + KResultOr<int> sys$mprotect(Userspace<void*>, size_t, int prot); + KResultOr<int> sys$madvise(Userspace<void*>, size_t, int advice); + KResultOr<int> sys$msyscall(Userspace<void*>); KResultOr<int> sys$purge(int mode); KResultOr<int> sys$select(Userspace<const Syscall::SC_select_params*>); KResultOr<int> sys$poll(Userspace<const Syscall::SC_poll_params*>); diff --git a/Kernel/Syscalls/mmap.cpp b/Kernel/Syscalls/mmap.cpp index 8802bd3f72..7f25a6fa08 100644 --- a/Kernel/Syscalls/mmap.cpp +++ b/Kernel/Syscalls/mmap.cpp @@ -145,7 +145,7 @@ KResultOr<FlatPtr> Process::sys$mmap(Userspace<const Syscall::SC_mmap_params*> u if (!copy_from_user(¶ms, user_params)) return EFAULT; - void* addr = (void*)params.addr; + FlatPtr addr = params.addr; size_t size = params.size; size_t alignment = params.alignment; int prot = params.prot; @@ -288,7 +288,7 @@ static KResultOr<Range> expand_range_to_page_boundaries(FlatPtr address, size_t return Range { base, end - base.get() }; } -KResultOr<int> Process::sys$mprotect(void* addr, size_t size, int prot) +KResultOr<int> Process::sys$mprotect(Userspace<void*> addr, size_t size, int prot) { REQUIRE_PROMISE(stdio); @@ -296,7 +296,7 @@ KResultOr<int> Process::sys$mprotect(void* addr, size_t size, int prot) REQUIRE_PROMISE(prot_exec); } - auto range_or_error = expand_range_to_page_boundaries((FlatPtr)addr, size); + auto range_or_error = expand_range_to_page_boundaries(addr, size); if (range_or_error.is_error()) return range_or_error.error(); @@ -366,11 +366,11 @@ KResultOr<int> Process::sys$mprotect(void* addr, size_t size, int prot) return EINVAL; } -KResultOr<int> Process::sys$madvise(void* address, size_t size, int advice) +KResultOr<int> Process::sys$madvise(Userspace<void*> address, size_t size, int advice) { REQUIRE_PROMISE(stdio); - auto range_or_error = expand_range_to_page_boundaries((FlatPtr)address, size); + auto range_or_error = expand_range_to_page_boundaries(address, size); if (range_or_error.is_error()) return range_or_error.error(); @@ -445,14 +445,14 @@ KResultOr<int> Process::sys$set_mmap_name(Userspace<const Syscall::SC_set_mmap_n return 0; } -KResultOr<int> Process::sys$munmap(void* addr, size_t size) +KResultOr<int> Process::sys$munmap(Userspace<void*> addr, size_t size) { REQUIRE_PROMISE(stdio); if (!size) return EINVAL; - auto range_or_error = expand_range_to_page_boundaries((FlatPtr)addr, size); + auto range_or_error = expand_range_to_page_boundaries(addr, size); if (range_or_error.is_error()) return range_or_error.error(); @@ -582,7 +582,7 @@ KResultOr<FlatPtr> Process::sys$allocate_tls(size_t size) return m_master_tls_region.unsafe_ptr()->vaddr().get(); } -KResultOr<int> Process::sys$msyscall(void* address) +KResultOr<int> Process::sys$msyscall(Userspace<void*> address) { if (space().enforces_syscall_regions()) return EPERM; |