mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-23 04:55:15 +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
Notes:
sideshowbarker
2024-07-19 07:36:12 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/236dcf77028
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
Reference in a new issue