mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:58:11 +00:00
Kernel: Assert that copy_to/from_user() are called with user addresses
This will panic the kernel immediately if these functions are misused so we can catch it and fix the misuse. This patch fixes a couple of misuses: - create_signal_trampolines() writes to a user-accessible page above the 3GB address mark. We should really get rid of this page but that's a whole other thing. - CoW faults need to use copy_from_user rather than copy_to_user since it's the *source* pointer that points to user memory. - Inode faults need to use memcpy rather than copy_to_user since we're copying a kernel stack buffer into a quickmapped page. This should make the copy_to/from_user() functions slightly less useful for exploitation. Before this, they were essentially just glorified memcpy() with SMAP disabled. :^)
This commit is contained in:
parent
2cd212e5df
commit
f7b394e9a1
6 changed files with 33 additions and 15 deletions
|
@ -1380,8 +1380,11 @@ void create_signal_trampolines()
|
|||
u8* trampoline_end = (u8*)asm_signal_trampoline_end;
|
||||
size_t trampoline_size = trampoline_end - trampoline;
|
||||
|
||||
u8* code_ptr = (u8*)trampoline_region->vaddr().as_ptr();
|
||||
copy_to_user(code_ptr, trampoline, trampoline_size);
|
||||
{
|
||||
SmapDisabler disabler;
|
||||
u8* code_ptr = (u8*)trampoline_region->vaddr().as_ptr();
|
||||
memcpy(code_ptr, trampoline, trampoline_size);
|
||||
}
|
||||
|
||||
trampoline_region->set_writable(false);
|
||||
trampoline_region->remap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue