page fault handler: protect thread accesses
current cpu's thread can be NULL during init, we don't want null derefs in the page fault handler Change-Id: I0a2c22b39cae2c258d211317cffc2408e19f3bbf
This commit is contained in:
committed by
Masamichi Takagi
parent
fe08ac4a67
commit
f5023c9730
@ -1563,7 +1563,7 @@ void
|
||||
unhandled_page_fault(struct thread *thread, void *fault_addr, void *regs)
|
||||
{
|
||||
const uintptr_t address = (uintptr_t)fault_addr;
|
||||
struct process_vm *vm = thread->vm;
|
||||
struct process_vm *vm;
|
||||
struct vm_range *range;
|
||||
unsigned long irqflags;
|
||||
unsigned long error = 0;
|
||||
@ -1578,6 +1578,11 @@ unhandled_page_fault(struct thread *thread, void *fault_addr, void *regs)
|
||||
(error & PF_RSVD ? "was" : "wasn't"),
|
||||
(error & PF_INSTR ? "was" : "wasn't"));
|
||||
|
||||
if (!thread)
|
||||
goto skipvm;
|
||||
|
||||
vm = thread->vm;
|
||||
|
||||
range = lookup_process_memory_range(vm, address, address+1);
|
||||
if (range) {
|
||||
__kprintf("address is in range, flag: 0x%lx\n",
|
||||
@ -1587,6 +1592,7 @@ unhandled_page_fault(struct thread *thread, void *fault_addr, void *regs)
|
||||
__kprintf("address is out of range! \n");
|
||||
}
|
||||
|
||||
skipvm:
|
||||
kprintf_unlock(irqflags);
|
||||
|
||||
/* TODO */
|
||||
|
||||
Reference in New Issue
Block a user