Prechádzať zdrojové kódy

Kernel: Remove copy_string_from_user() as it's no longer used

Andreas Kling 4 rokov pred
rodič
commit
96d5d017b7
3 zmenil súbory, kde vykonal 0 pridanie a 36 odobranie
  1. 0 5
      Kernel/Process.h
  2. 0 29
      Kernel/StdLib.cpp
  3. 0 2
      Kernel/StdLib.h

+ 0 - 5
Kernel/Process.h

@@ -986,11 +986,6 @@ inline ProcessID Thread::pid() const
 #define VERIFY_NO_PROCESS_BIG_LOCK(process) \
     VERIFY(!process->big_lock().own_lock());
 
-inline static String copy_string_from_user(const Kernel::Syscall::StringArgument& string)
-{
-    return copy_string_from_user(string.characters, string.length);
-}
-
 inline static KResultOr<NonnullOwnPtr<KString>> try_copy_kstring_from_user(const Kernel::Syscall::StringArgument& string)
 {
     Userspace<char const*> characters((FlatPtr)string.characters);

+ 0 - 29
Kernel/StdLib.cpp

@@ -13,35 +13,6 @@
 #include <Kernel/Memory/MemoryManager.h>
 #include <Kernel/StdLib.h>
 
-String copy_string_from_user(const char* user_str, size_t user_str_size)
-{
-    bool is_user = Kernel::Memory::is_user_range(VirtualAddress(user_str), user_str_size);
-    if (!is_user)
-        return {};
-    Kernel::SmapDisabler disabler;
-    void* fault_at;
-    ssize_t length = Kernel::safe_strnlen(user_str, user_str_size, fault_at);
-    if (length < 0) {
-        dbgln("copy_string_from_user({:p}, {}) failed at {} (strnlen)", static_cast<const void*>(user_str), user_str_size, VirtualAddress { fault_at });
-        return {};
-    }
-    if (length == 0)
-        return String::empty();
-
-    char* buffer;
-    auto copied_string = StringImpl::create_uninitialized((size_t)length, buffer);
-    if (!Kernel::safe_memcpy(buffer, user_str, (size_t)length, fault_at)) {
-        dbgln("copy_string_from_user({:p}, {}) failed at {} (memcpy)", static_cast<const void*>(user_str), user_str_size, VirtualAddress { fault_at });
-        return {};
-    }
-    return copied_string;
-}
-
-String copy_string_from_user(Userspace<const char*> user_str, size_t user_str_size)
-{
-    return copy_string_from_user(user_str.unsafe_userspace_ptr(), user_str_size);
-}
-
 Kernel::KResultOr<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(Userspace<const char*> user_str, size_t user_str_size)
 {
     bool is_user = Kernel::Memory::is_user_range(VirtualAddress(user_str), user_str_size);

+ 0 - 2
Kernel/StdLib.h

@@ -18,8 +18,6 @@ namespace Syscall {
 struct StringArgument;
 }
 
-[[nodiscard]] String copy_string_from_user(const char*, size_t);
-[[nodiscard]] String copy_string_from_user(Userspace<const char*>, size_t);
 [[nodiscard]] Kernel::KResultOr<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(Userspace<const char*>, size_t);
 [[nodiscard]] Optional<Time> copy_time_from_user(const timespec*);
 [[nodiscard]] Optional<Time> copy_time_from_user(const timeval*);