Don't call crcopysafe or uifind unnecessarily in execve.
MFC after: 1 week
This commit is contained in:
parent
be78a8db97
commit
350d51816e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=268087
@ -336,7 +336,7 @@ do_execve(td, args, mac_p)
|
||||
struct proc *p = td->td_proc;
|
||||
struct nameidata nd;
|
||||
struct ucred *newcred = NULL, *oldcred;
|
||||
struct uidinfo *euip;
|
||||
struct uidinfo *euip = NULL;
|
||||
register_t *stack_base;
|
||||
int error, i;
|
||||
struct image_params image_params, *imgp;
|
||||
@ -601,8 +601,6 @@ do_execve(td, args, mac_p)
|
||||
/*
|
||||
* Malloc things before we need locks.
|
||||
*/
|
||||
newcred = crget();
|
||||
euip = uifind(attr.va_uid);
|
||||
i = imgp->args->begin_envv - imgp->args->begin_argv;
|
||||
/* Cache arguments if they fit inside our allowance */
|
||||
if (ps_arg_cache_limit >= i + sizeof(struct pargs)) {
|
||||
@ -631,7 +629,7 @@ do_execve(td, args, mac_p)
|
||||
PROC_LOCK(p);
|
||||
if (oldsigacts)
|
||||
p->p_sigacts = newsigacts;
|
||||
oldcred = crcopysafe(p, newcred);
|
||||
oldcred = p->p_ucred;
|
||||
/* Stop profiling */
|
||||
stopprofclock(p);
|
||||
|
||||
@ -721,6 +719,8 @@ do_execve(td, args, mac_p)
|
||||
vn_lock(imgp->vp, LK_SHARED | LK_RETRY);
|
||||
if (error != 0)
|
||||
goto done1;
|
||||
newcred = crdup(oldcred);
|
||||
euip = uifind(attr.va_uid);
|
||||
PROC_LOCK(p);
|
||||
/*
|
||||
* Set the new credentials.
|
||||
@ -745,7 +745,6 @@ do_execve(td, args, mac_p)
|
||||
change_svuid(newcred, newcred->cr_uid);
|
||||
change_svgid(newcred, newcred->cr_gid);
|
||||
p->p_ucred = newcred;
|
||||
newcred = NULL;
|
||||
} else {
|
||||
if (oldcred->cr_uid == oldcred->cr_ruid &&
|
||||
oldcred->cr_gid == oldcred->cr_rgid)
|
||||
@ -764,10 +763,12 @@ do_execve(td, args, mac_p)
|
||||
*/
|
||||
if (oldcred->cr_svuid != oldcred->cr_uid ||
|
||||
oldcred->cr_svgid != oldcred->cr_gid) {
|
||||
PROC_UNLOCK(p);
|
||||
newcred = crdup(oldcred);
|
||||
PROC_LOCK(p);
|
||||
change_svuid(newcred, newcred->cr_uid);
|
||||
change_svgid(newcred, newcred->cr_gid);
|
||||
p->p_ucred = newcred;
|
||||
newcred = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -844,11 +845,10 @@ do_execve(td, args, mac_p)
|
||||
/*
|
||||
* Free any resources malloc'd earlier that we didn't use.
|
||||
*/
|
||||
uifree(euip);
|
||||
if (newcred == NULL)
|
||||
if (euip != NULL)
|
||||
uifree(euip);
|
||||
if (newcred != NULL)
|
||||
crfree(oldcred);
|
||||
else
|
||||
crfree(newcred);
|
||||
VOP_UNLOCK(imgp->vp, 0);
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user