1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:58:13 +00:00

Kernel: Remove SmapDisablers in open(), openat() and set_thread_name()

This patch introduces a helpful copy_string_from_user() function
that takes a bounded null-terminated string from userspace memory
and copies it into a String object.
This commit is contained in:
Andreas Kling 2020-01-05 21:51:06 +01:00
parent c4a1ea34c2
commit 80cbb72f2f
3 changed files with 37 additions and 33 deletions

View file

@ -1,9 +1,17 @@
#include <AK/Assertions.h>
#include <AK/String.h>
#include <AK/Types.h>
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/Heap/kmalloc.h>
#include <Kernel/StdLib.h>
String copy_string_from_user(const char* user_str, size_t user_str_size)
{
SmapDisabler disabler;
size_t length = strnlen(user_str, user_str_size);
return String(user_str, length);
}
extern "C" {
void* copy_to_user(void* dest_ptr, const void* src_ptr, size_t n)