mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:57:44 +00:00
Kernel: Wrap process address spaces in SpinlockProtected
This forces anyone who wants to look into and/or manipulate an address space to lock it. And this replaces the previous, more flimsy, manual spinlock use. Note that pointers *into* the address space are not safe to use after you unlock the space. We've got many issues like this, and we'll have to track those down as wlel.
This commit is contained in:
parent
d6ef18f587
commit
cf16b2c8e6
38 changed files with 708 additions and 627 deletions
|
@ -303,9 +303,15 @@ void page_fault_handler(TrapFrame* trap)
|
|||
};
|
||||
|
||||
VirtualAddress userspace_sp = VirtualAddress { regs.userspace_sp() };
|
||||
if (!faulted_in_kernel && !MM.validate_user_stack(current_thread->process().address_space(), userspace_sp)) {
|
||||
dbgln("Invalid stack pointer: {}", userspace_sp);
|
||||
return handle_crash(regs, "Bad stack on page fault", SIGSEGV);
|
||||
|
||||
if (!faulted_in_kernel) {
|
||||
bool has_valid_stack_pointer = current_thread->process().address_space().with([&](auto& space) {
|
||||
return MM.validate_user_stack(*space, userspace_sp);
|
||||
});
|
||||
if (!has_valid_stack_pointer) {
|
||||
dbgln("Invalid stack pointer: {}", userspace_sp);
|
||||
return handle_crash(regs, "Bad stack on page fault", SIGSEGV);
|
||||
}
|
||||
}
|
||||
|
||||
PageFault fault { regs.exception_code, VirtualAddress { fault_address } };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue