mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-15 10:17:20 +00:00
Don't grab Giant in crfree(), since prison_free() no longer requires it.
The uidinfo code appears to be MPSAFE, and is referenced without Giant elsewhere. While this grab of Giant was only made in fairly rare circumstances (actually GC'ing on refcount==0), grabbing Giant here potentially introduces lock order issues with any locks held by the caller. So this probably won't help performance much unless you change credentials a lot in an application, and leave a lot of file descriptors and cached credentials around. However, it simplifies locking down consumers of the credential interfaces. Bumped into by: sam Appeased: tjr
This commit is contained in:
parent
799426f877
commit
646e29ccac
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=124884
@ -1746,13 +1746,12 @@ crfree(struct ucred *cr)
|
||||
mtx_lock(mtxp);
|
||||
KASSERT(cr->cr_ref > 0, ("bad ucred refcount: %d", cr->cr_ref));
|
||||
if (--cr->cr_ref == 0) {
|
||||
mtx_unlock(mtxp);
|
||||
/*
|
||||
* Some callers of crget(), such as nfs_statfs(),
|
||||
* allocate a temporary credential, but don't
|
||||
* allocate a uidinfo structure.
|
||||
*/
|
||||
mtx_unlock(mtxp);
|
||||
mtx_lock(&Giant);
|
||||
if (cr->cr_uidinfo != NULL)
|
||||
uifree(cr->cr_uidinfo);
|
||||
if (cr->cr_ruidinfo != NULL)
|
||||
@ -1766,7 +1765,6 @@ crfree(struct ucred *cr)
|
||||
mac_destroy_cred(cr);
|
||||
#endif
|
||||
FREE(cr, M_CRED);
|
||||
mtx_unlock(&Giant);
|
||||
} else {
|
||||
mtx_unlock(mtxp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user