Parcourir la source

Kernel: Use Userspace<T> for the getrandom syscall

Brian Gianforcaro il y a 5 ans
Parent
commit
b5a2a215f6
2 fichiers modifiés avec 4 ajouts et 3 suppressions
  1. 1 1
      Kernel/Process.h
  2. 3 2
      Kernel/Syscalls/getrandom.cpp

+ 1 - 1
Kernel/Process.h

@@ -323,7 +323,7 @@ public:
     int sys$reboot();
     int sys$set_process_icon(int icon_id);
     int sys$realpath(Userspace<const Syscall::SC_realpath_params*>);
-    ssize_t sys$getrandom(void*, size_t, unsigned int);
+    ssize_t sys$getrandom(Userspace<void*>, size_t, unsigned int);
     int sys$setkeymap(Userspace<const Syscall::SC_setkeymap_params*>);
     int sys$module_load(const char* path, size_t path_length);
     int sys$module_unload(const char* name, size_t name_length);

+ 3 - 2
Kernel/Syscalls/getrandom.cpp

@@ -32,7 +32,7 @@ namespace Kernel {
 // We don't use the flag yet, but we could use it for distinguishing
 // random source like Linux, unlike the OpenBSD equivalent. However, if we
 // do, we should be able of the caveats that Linux has dealt with.
-ssize_t Process::sys$getrandom(void* buffer, size_t buffer_size, [[maybe_unused]] unsigned flags)
+ssize_t Process::sys$getrandom(Userspace<void*> buffer, size_t buffer_size, [[maybe_unused]] unsigned flags)
 {
     REQUIRE_PROMISE(stdio);
     if (buffer_size <= 0)
@@ -42,7 +42,8 @@ ssize_t Process::sys$getrandom(void* buffer, size_t buffer_size, [[maybe_unused]
         return -EFAULT;
 
     SmapDisabler disabler;
-    get_good_random_bytes((u8*)buffer, buffer_size);
+    // FIXME: We should really push Userspace<T> down through the interface.
+    get_good_random_bytes((u8*)buffer.ptr(), buffer_size);
     return 0;
 }