Kernel: Use Userspace<T> for the getrandom syscall

This commit is contained in:
Brian Gianforcaro 2020-08-09 15:35:06 -07:00 committed by Andreas Kling
parent c8ae244ab8
commit b5a2a215f6
2 changed files with 4 additions and 3 deletions

View file

@ -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);

View file

@ -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;
}