diff options
author | alfred <alfred@FreeBSD.org> | 2002-06-19 06:39:25 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2002-06-19 06:39:25 +0000 |
commit | bfa1cb192ccc7451cb1191150e479dbe394f212f (patch) | |
tree | eb114f0da986c26c412286c513b7911b9eb0fb74 /sys/kern/kern_exec.c | |
parent | 1da636b9f46629c676e995f1e52ba9d553db90c6 (diff) | |
download | FreeBSD-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/kern/kern_exec.c')
-rw-r--r-- | sys/kern/kern_exec.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 913f951..39da17e 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -128,6 +128,7 @@ execve(td, uap) struct proc *p = td->td_proc; struct nameidata nd, *ndp; struct ucred *newcred = NULL, *oldcred; + struct uidinfo *euip; register_t *stack_base; int error, len, i; struct image_params image_params, *imgp; @@ -303,6 +304,7 @@ interpret: * Malloc things before we need locks. */ newcred = crget(); + euip = uifind(attr.va_uid); i = imgp->endargs - imgp->stringbase; if (ps_arg_cache_limit >= i + sizeof(struct pargs)) newargs = pargs_alloc(i); @@ -390,7 +392,7 @@ interpret: */ crcopy(newcred, oldcred); if (attr.va_mode & VSUID) - change_euid(newcred, attr.va_uid); + change_euid(newcred, euip); if (attr.va_mode & VSGID) change_egid(newcred, attr.va_gid); setugidsafety(td); @@ -472,6 +474,7 @@ interpret: /* * Free any resources malloc'd earlier that we didn't use. */ + uifree(euip); if (newcred == NULL) crfree(oldcred); else |