summaryrefslogtreecommitdiffstats
path: root/sys/alpha/osf1
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2002-06-19 06:39:25 +0000
committeralfred <alfred@FreeBSD.org>2002-06-19 06:39:25 +0000
commitbfa1cb192ccc7451cb1191150e479dbe394f212f (patch)
treeeb114f0da986c26c412286c513b7911b9eb0fb74 /sys/alpha/osf1
parent1da636b9f46629c676e995f1e52ba9d553db90c6 (diff)
downloadFreeBSD-src-bfa1cb192ccc7451cb1191150e479dbe394f212f.zip
FreeBSD-src-bfa1cb192ccc7451cb1191150e479dbe394f212f.tar.gz
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 <dl-freebsd@catspoiler.org>
Diffstat (limited to 'sys/alpha/osf1')
-rw-r--r--sys/alpha/osf1/osf1_misc.c8
1 files changed, 6 insertions, 2 deletions
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);
}
OpenPOWER on IntegriCloud