Use crcopysafe(9) to make a copy of a process' credential struct. crcopy(9)

may perform a blocking memory allocation, which is unsafe when holding a
mutex.

Differential Revision:	https://reviews.freebsd.org/D1443
Reviewed by:	rwatson
MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
Mark Johnston 2015-01-05 23:07:22 +00:00
parent 08b96b9ff5
commit bbd685e3a5

View file

@ -102,8 +102,7 @@ sys_cap_enter(struct thread *td, struct cap_enter_args *uap)
newcred = crget();
p = td->td_proc;
PROC_LOCK(p);
oldcred = p->p_ucred;
crcopy(newcred, oldcred);
oldcred = crcopysafe(p, newcred);
newcred->cr_flags |= CRED_FLAG_CAPMODE;
p->p_ucred = newcred;
PROC_UNLOCK(p);