* In-kernel implementation of execve(). All arguments are assumed to be * userspace pointers from the passed thread. */
| 358 | * userspace pointers from the passed thread. |
| 359 | */ |
| 360 | static int |
| 361 | do_execve(struct thread *td, struct image_args *args, struct mac *mac_p, |
| 362 | struct vmspace *oldvmspace) |
| 363 | { |
| 364 | struct proc *p = td->td_proc; |
| 365 | struct nameidata nd; |
| 366 | struct ucred *oldcred; |
| 367 | struct uidinfo *euip = NULL; |
| 368 | uintptr_t stack_base; |
| 369 | struct image_params image_params, *imgp; |
| 370 | struct vattr attr; |
| 371 | int (*img_first)(struct image_params *); |
| 372 | struct pargs *oldargs = NULL, *newargs = NULL; |
| 373 | struct sigacts *oldsigacts = NULL, *newsigacts = NULL; |
| 374 | #ifdef KTRACE |
| 375 | struct vnode *tracevp = NULL; |
| 376 | struct ucred *tracecred = NULL; |
| 377 | #endif |
| 378 | struct vnode *oldtextvp = NULL, *newtextvp; |
| 379 | int credential_changing; |
| 380 | #ifdef MAC |
| 381 | struct label *interpvplabel = NULL; |
| 382 | int will_transition; |
| 383 | #endif |
| 384 | #ifdef HWPMC_HOOKS |
| 385 | struct pmckern_procexec pe; |
| 386 | #endif |
| 387 | int error, i, orig_osrel; |
| 388 | uint32_t orig_fctl0; |
| 389 | static const char fexecv_proc_title[] = "(fexecv)"; |
| 390 | |
| 391 | imgp = &image_params; |
| 392 | |
| 393 | /* |
| 394 | * Lock the process and set the P_INEXEC flag to indicate that |
| 395 | * it should be left alone until we're done here. This is |
| 396 | * necessary to avoid race conditions - e.g. in ptrace() - |
| 397 | * that might allow a local user to illicitly obtain elevated |
| 398 | * privileges. |
| 399 | */ |
| 400 | PROC_LOCK(p); |
| 401 | KASSERT((p->p_flag & P_INEXEC) == 0, |
| 402 | ("%s(): process already has P_INEXEC flag", __func__)); |
| 403 | p->p_flag |= P_INEXEC; |
| 404 | PROC_UNLOCK(p); |
| 405 | |
| 406 | /* |
| 407 | * Initialize part of the common data |
| 408 | */ |
| 409 | bzero(imgp, sizeof(*imgp)); |
| 410 | imgp->proc = p; |
| 411 | imgp->attr = &attr; |
| 412 | imgp->args = args; |
| 413 | oldcred = p->p_ucred; |
| 414 | orig_osrel = p->p_osrel; |
| 415 | orig_fctl0 = p->p_fctl0; |
| 416 | |
| 417 | #ifdef MAC |
no test coverage detected