The user_ldt_alloc() function shall return with dt_lock locked.
The user_ldt_free() function shall return with dt_lock unlocked. Error handling code in both functions do not handle this, fix it by doing necessary lock/unlock. While there, fix minor style nits. MFC after: 1 week
This commit is contained in:
parent
56d456a5d3
commit
cb1d78d09a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=182960
@ -444,8 +444,9 @@ user_ldt_alloc(struct mdproc *mdp, int len)
|
||||
new_ldt->ldt_base = (caddr_t)kmem_alloc(kernel_map,
|
||||
round_page(len * sizeof(union descriptor)));
|
||||
if (new_ldt->ldt_base == NULL) {
|
||||
FREE(new_ldt, M_SUBPROC);
|
||||
return NULL;
|
||||
FREE(new_ldt, M_SUBPROC);
|
||||
mtx_lock_spin(&dt_lock);
|
||||
return (NULL);
|
||||
}
|
||||
new_ldt->ldt_refcnt = 1;
|
||||
new_ldt->ldt_active = 0;
|
||||
@ -460,7 +461,7 @@ user_ldt_alloc(struct mdproc *mdp, int len)
|
||||
}
|
||||
pmap_map_readonly(kernel_pmap, (vm_offset_t)new_ldt->ldt_base,
|
||||
new_ldt->ldt_len*sizeof(union descriptor));
|
||||
return new_ldt;
|
||||
return (new_ldt);
|
||||
}
|
||||
#else
|
||||
/*
|
||||
@ -481,7 +482,8 @@ user_ldt_alloc(struct mdproc *mdp, int len)
|
||||
len * sizeof(union descriptor));
|
||||
if (new_ldt->ldt_base == NULL) {
|
||||
FREE(new_ldt, M_SUBPROC);
|
||||
return NULL;
|
||||
mtx_lock_spin(&dt_lock);
|
||||
return (NULL);
|
||||
}
|
||||
new_ldt->ldt_refcnt = 1;
|
||||
new_ldt->ldt_active = 0;
|
||||
@ -513,8 +515,10 @@ user_ldt_free(struct thread *td)
|
||||
struct proc_ldt *pldt;
|
||||
|
||||
mtx_assert(&dt_lock, MA_OWNED);
|
||||
if ((pldt = mdp->md_ldt) == NULL)
|
||||
if ((pldt = mdp->md_ldt) == NULL) {
|
||||
mtx_unlock_spin(&dt_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
if (td == PCPU_GET(curthread)) {
|
||||
lldt(_default_ldt);
|
||||
|
Loading…
Reference in New Issue
Block a user