Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_exec.c
Show First 20 Lines • Show All 350 Lines • ▼ Show 20 Lines | kern_execve(struct thread *td, struct image_args *args, struct mac *mac_p, | ||||
struct vmspace *oldvmspace) | struct vmspace *oldvmspace) | ||||
{ | { | ||||
TSEXEC(td->td_proc->p_pid, args->begin_argv); | TSEXEC(td->td_proc->p_pid, args->begin_argv); | ||||
AUDIT_ARG_ARGV(args->begin_argv, args->argc, | AUDIT_ARG_ARGV(args->begin_argv, args->argc, | ||||
exec_args_get_begin_envv(args) - args->begin_argv); | exec_args_get_begin_envv(args) - args->begin_argv); | ||||
AUDIT_ARG_ENVV(exec_args_get_begin_envv(args), args->envc, | AUDIT_ARG_ENVV(exec_args_get_begin_envv(args), args->envc, | ||||
args->endp - exec_args_get_begin_envv(args)); | args->endp - exec_args_get_begin_envv(args)); | ||||
/* | |||||
* Must have at least one argument. Bail out after auditing, rather | |||||
* than before, in case empty argv is significant to some audit-based | |||||
* IDS. Probably not a big deal right now, given that this is the only | |||||
emaste: I don't see what you mean by "probably not a big deal right now."
| |||||
kevansAuthorUnsubmitted Done Inline ActionsYeah, I'll drop that. That was an addition from the thought that right now one can surmise from an EINVAL failure that argc == 0 if the manpage is to be believed, but a future change could return EINVAL for some other scenario we aren't thinking of. Either way, this comment could likely be reduced again to just "Must have at least one argument." because auditing the args should generally happen even if they're invalid anyways. kevans: Yeah, I'll drop that. That was an addition from the thought that right now one can surmise from… | |||||
* EINVAL documented for execve(2). | |||||
*/ | |||||
if (args->argc == 0) | |||||
return (EINVAL); | |||||
kevansAuthorUnsubmitted Done Inline ActionsSigh, this leaks; added exec_free_args(args); locally kevans: Sigh, this leaks; added `exec_free_args(args);` locally | |||||
return (do_execve(td, args, mac_p, oldvmspace)); | return (do_execve(td, args, mac_p, oldvmspace)); | ||||
} | } | ||||
static void | static void | ||||
execve_nosetid(struct image_params *imgp) | execve_nosetid(struct image_params *imgp) | ||||
{ | { | ||||
imgp->credential_setid = false; | imgp->credential_setid = false; | ||||
if (imgp->newcred != NULL) { | if (imgp->newcred != NULL) { | ||||
▲ Show 20 Lines • Show All 935 Lines • ▼ Show 20 Lines | if (arg == 0) | ||||
break; | break; | ||||
error = exec_args_add_arg(args, (char *)(uintptr_t)arg, | error = exec_args_add_arg(args, (char *)(uintptr_t)arg, | ||||
UIO_USERSPACE); | UIO_USERSPACE); | ||||
if (error != 0) | if (error != 0) | ||||
goto err_exit; | goto err_exit; | ||||
} | } | ||||
/* | /* | ||||
* extract environment strings | * extract environment strings | ||||
Not Done Inline Actionsfreebsd32 has its own freebsd32_exec_copyin_args. Maybe better to punt this to kern_execve? jrtc27: freebsd32 has its own freebsd32_exec_copyin_args. Maybe better to punt this to kern_execve? | |||||
Done Inline ActionsYeah, or top of do_execve... kevans: Yeah, or top of do_execve... | |||||
*/ | */ | ||||
if (envv) { | if (envv) { | ||||
for (;;) { | for (;;) { | ||||
error = fueword(envv++, &env); | error = fueword(envv++, &env); | ||||
if (error == -1) { | if (error == -1) { | ||||
error = EFAULT; | error = EFAULT; | ||||
goto err_exit; | goto err_exit; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 722 Lines • Show Last 20 Lines |
I don't see what you mean by "probably not a big deal right now."