diff options
author | truckman <truckman@FreeBSD.org> | 2005-10-01 08:33:56 +0000 |
---|---|---|
committer | truckman <truckman@FreeBSD.org> | 2005-10-01 08:33:56 +0000 |
commit | 6c6c328bd0bbb1d9f6b3230a33d194bf961b0eae (patch) | |
tree | f917508e81d42bf420694b6b21cd75f448153d5f /sys/kern/kern_exec.c | |
parent | c29899efe70a279bff89aa4cee4f14a19be157b9 (diff) | |
download | FreeBSD-src-6c6c328bd0bbb1d9f6b3230a33d194bf961b0eae.zip FreeBSD-src-6c6c328bd0bbb1d9f6b3230a33d194bf961b0eae.tar.gz |
Copy new process argument list in do_execve() before grabbing PROC_LOCK
to avoid touching pageable memory while holding a mutex.
Simplify argument list replacement logic.
PR: kern/84935
Submitted by: "Antoine Pelisse" apelisse AT gmail.com (in a different form)
MFC after: 3 days
Diffstat (limited to 'sys/kern/kern_exec.c')
-rw-r--r-- | sys/kern/kern_exec.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 719f5bb..689f88d 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -479,8 +479,11 @@ interpret: newcred = crget(); euip = uifind(attr.va_uid); i = imgp->args->begin_envv - imgp->args->begin_argv; - if (ps_arg_cache_limit >= i + sizeof(struct pargs)) + /* Cache arguments if they fit inside our allowance */ + if (ps_arg_cache_limit >= i + sizeof(struct pargs)) { newargs = pargs_alloc(i); + bcopy(imgp->args->begin_argv, newargs->ar_args, i); + } /* close files on exec */ fdcloseexec(td); @@ -661,16 +664,13 @@ interpret: /* clear "fork but no exec" flag, as we _are_ execing */ p->p_acflag &= ~AFORK; - /* Free any previous argument cache */ + /* + * Free any previous argument cache and it with + * the new argument cache, if any. + */ oldargs = p->p_args; - p->p_args = NULL; - - /* Cache arguments if they fit inside our allowance */ - if (ps_arg_cache_limit >= i + sizeof(struct pargs)) { - bcopy(imgp->args->begin_argv, newargs->ar_args, i); - p->p_args = newargs; - newargs = NULL; - } + p->p_args = newargs; + newargs = NULL; #ifdef HWPMC_HOOKS /* |