mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:37:36 +00:00
LibBareMetal: Add more assertions in copy_{to,from}_user()
Assert that the source/destination address is in kernel space when appropriate. This is mostly to give ourselves an error if we're doing something we were not expecting to be doing.
This commit is contained in:
parent
815b73bdcc
commit
236dcf7702
1 changed files with 2 additions and 0 deletions
|
@ -50,6 +50,7 @@ extern "C" {
|
|||
void copy_to_user(void* dest_ptr, const void* src_ptr, size_t n)
|
||||
{
|
||||
ASSERT(Kernel::is_user_range(VirtualAddress(dest_ptr), n));
|
||||
ASSERT(!Kernel::is_user_range(VirtualAddress(src_ptr), n));
|
||||
Kernel::SmapDisabler disabler;
|
||||
memcpy(dest_ptr, src_ptr, n);
|
||||
}
|
||||
|
@ -57,6 +58,7 @@ void copy_to_user(void* dest_ptr, const void* src_ptr, size_t n)
|
|||
void copy_from_user(void* dest_ptr, const void* src_ptr, size_t n)
|
||||
{
|
||||
ASSERT(Kernel::is_user_range(VirtualAddress(src_ptr), n));
|
||||
ASSERT(!Kernel::is_user_range(VirtualAddress(dest_ptr), n));
|
||||
Kernel::SmapDisabler disabler;
|
||||
memcpy(dest_ptr, src_ptr, n);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue