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:
parent
c4a1ea34c2
commit
80cbb72f2f
3 changed files with 37 additions and 33 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue