Jelajahi Sumber

Kernel: SMAP fixes for module_load() and module_unload()

Remove SmapDisabler in module_load() + use get_syscall_path_argument().
Also fix a SMAP violation in module_unload().
Andreas Kling 5 tahun lalu
induk
melakukan
a30fb5c5c1
1 mengubah file dengan 9 tambahan dan 6 penghapusan
  1. 9 6
      Kernel/Process.cpp

+ 9 - 6
Kernel/Process.cpp

@@ -3827,14 +3827,15 @@ int Process::sys$beep()
     return 0;
     return 0;
 }
 }
 
 
-int Process::sys$module_load(const char* path, size_t path_length)
+int Process::sys$module_load(const char* user_path, size_t path_length)
 {
 {
     if (!is_superuser())
     if (!is_superuser())
         return -EPERM;
         return -EPERM;
-    if (!validate_read(path, path_length))
-        return -EFAULT;
-    SmapDisabler disabler;
-    auto description_or_error = VFS::the().open(path, 0, 0, current_directory());
+
+    auto path = get_syscall_path_argument(user_path, path_length);
+    if (path.is_error())
+        return path.error();
+    auto description_or_error = VFS::the().open(path.value(), 0, 0, current_directory());
     if (description_or_error.is_error())
     if (description_or_error.is_error())
         return description_or_error.error();
         return description_or_error.error();
     auto& description = description_or_error.value();
     auto& description = description_or_error.value();
@@ -3952,7 +3953,9 @@ int Process::sys$module_unload(const char* name, size_t name_length)
     if (!validate_read(name, name_length))
     if (!validate_read(name, name_length))
         return -EFAULT;
         return -EFAULT;
 
 
-    auto it = g_modules->find(name);
+    auto module_name = copy_string_from_user(name, name_length);
+
+    auto it = g_modules->find(module_name);
     if (it == g_modules->end())
     if (it == g_modules->end())
         return -ENOENT;
         return -ENOENT;