mem: ensure proc_mmap is only called when locked
This commit is contained in:
parent
9c5d722f72
commit
8ea5c58fef
2 changed files with 7 additions and 4 deletions
|
|
@ -257,8 +257,8 @@ paddr_t proc_clone_mmap(struct proc *in, struct proc *out)
|
|||
out->cr3 &= ~hhdm_start;
|
||||
|
||||
/* copy all mappings */
|
||||
spinlock_acquire(&in->page_map_lock);
|
||||
spinlock_acquire(&out->page_map_lock);
|
||||
spinlock_acquire(&in->lock);
|
||||
spinlock_acquire(&out->lock);
|
||||
|
||||
struct rbnode *node = rbt_minimum(in->page_map.root);
|
||||
|
||||
|
|
@ -273,8 +273,8 @@ paddr_t proc_clone_mmap(struct proc *in, struct proc *out)
|
|||
node = rbt_successor(node);
|
||||
}
|
||||
|
||||
spinlock_release(&in->page_map_lock);
|
||||
spinlock_release(&out->page_map_lock);
|
||||
spinlock_release(&in->lock);
|
||||
spinlock_release(&out->lock);
|
||||
|
||||
return out->cr3;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ pid_t elf_load_proc(char *fname)
|
|||
|
||||
struct proc *proc = proc_create();
|
||||
/* allocate page tables */
|
||||
spinlock_acquire(&proc->lock);
|
||||
proc->cr3 = (uintptr_t)buddy_alloc(0x1000);
|
||||
|
||||
/* map kernel pages */
|
||||
|
|
@ -114,5 +115,7 @@ pid_t elf_load_proc(char *fname)
|
|||
|
||||
kfree(buf);
|
||||
|
||||
spinlock_release(&proc->lock);
|
||||
|
||||
return proc->pid;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue