From bfa1cb192ccc7451cb1191150e479dbe394f212f Mon Sep 17 00:00:00 2001 From: alfred Date: Wed, 19 Jun 2002 06:39:25 +0000 Subject: Squish the "could sleep with process lock" messages caused by calling uifind() with a proc lock held. change_ruid() and change_euid() have been modified to take a uidinfo structure which will be pre-allocated by callers, they will then call uihold() on the uidinfo structure so that the caller's logic is simplified. This allows one to call uifind() before locking the proc struct and thereby avoid a potential blocking allocation with the proc lock held. This may need revisiting, perhaps keeping a spare uidinfo allocated per process to handle this situation or re-examining if the proc lock needs to be held over the entire operation of changing real or effective user id. Submitted by: Don Lewis --- sys/alpha/osf1/osf1_misc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sys/alpha/osf1') diff --git a/sys/alpha/osf1/osf1_misc.c b/sys/alpha/osf1/osf1_misc.c index 8a89891..0b74fab 100644 --- a/sys/alpha/osf1/osf1_misc.c +++ b/sys/alpha/osf1/osf1_misc.c @@ -1056,17 +1056,20 @@ osf1_setuid(td, uap) struct proc *p; int error; uid_t uid; + struct uidinfo *uip; struct ucred *newcred, *oldcred; p = td->td_proc; uid = SCARG(uap, uid); newcred = crget(); + uip = uifind(uid); PROC_LOCK(p); oldcred = p->p_ucred; if ((error = suser_cred(p->p_ucred, PRISON_ROOT)) != 0 && uid != oldcred->cr_ruid && uid != oldcred->cr_svuid) { PROC_UNLOCK(p); + uifree(uip); crfree(newcred); return (error); } @@ -1074,7 +1077,7 @@ osf1_setuid(td, uap) crcopy(newcred, oldcred); if (error == 0) { if (uid != oldcred->cr_ruid) { - change_ruid(newcred, uid); + change_ruid(newcred, uip); setsugid(p); } if (oldcred->cr_svuid != uid) { @@ -1083,11 +1086,12 @@ osf1_setuid(td, uap) } } if (newcred->cr_uid != uid) { - change_euid(newcred, uid); + change_euid(newcred, uip); setsugid(p); } p->p_ucred = newcred; PROC_UNLOCK(p); + uifree(uip); crfree(oldcred); return (0); } -- cgit v1.1