Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/imgact_elf.c
Show First 20 Lines • Show All 817 Lines • ▼ Show 20 Lines | #endif | ||||
NDINIT(nd, LOOKUP, ISOPEN | FOLLOW | LOCKSHARED | LOCKLEAF, | NDINIT(nd, LOOKUP, ISOPEN | FOLLOW | LOCKSHARED | LOCKLEAF, | ||||
UIO_SYSSPACE, file); | UIO_SYSSPACE, file); | ||||
if ((error = namei(nd)) != 0) { | if ((error = namei(nd)) != 0) { | ||||
nd->ni_vp = NULL; | nd->ni_vp = NULL; | ||||
goto fail; | goto fail; | ||||
} | } | ||||
NDFREE_PNBUF(nd); | NDFREE_PNBUF(nd); | ||||
imgp->vp = nd->ni_vp; | imgp->vp = nd->ni_vp; | ||||
dchagin: this can be avoided if namei() clean ni_vp on error path | |||||
/* | /* | ||||
* Check permissions, modes, uid, etc on the file, and "open" it. | * Check permissions, modes, uid, etc on the file, and "open" it. | ||||
*/ | */ | ||||
error = exec_check_permissions(imgp); | error = exec_check_permissions(imgp); | ||||
if (error) | if (error) | ||||
goto fail; | goto fail; | ||||
error = exec_map_first_page(imgp); | error = exec_map_first_page(imgp); | ||||
▲ Show 20 Lines • Show All 229 Lines • ▼ Show 20 Lines | __elfN(get_interp)(struct image_params *imgp, const Elf_Phdr *phdr, | ||||
*free_interpp = false; | *free_interpp = false; | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
__elfN(load_interp)(struct image_params *imgp, const Elf_Brandinfo *brand_info, | __elfN(load_interp)(struct image_params *imgp, const Elf_Brandinfo *brand_info, | ||||
const char *interp, u_long *addr, u_long *entry) | const char *interp, u_long *addr, u_long *entry) | ||||
{ | { | ||||
char *path; | |||||
int error; | int error; | ||||
if (brand_info->emul_path != NULL && | |||||
brand_info->emul_path[0] != '\0') { | |||||
path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); | |||||
snprintf(path, MAXPATHLEN, "%s%s", | |||||
brand_info->emul_path, interp); | |||||
error = __elfN(load_file)(imgp->proc, path, addr, entry); | |||||
free(path, M_TEMP); | |||||
if (error == 0) | |||||
return (0); | |||||
} | |||||
if (brand_info->interp_newpath != NULL && | if (brand_info->interp_newpath != NULL && | ||||
(brand_info->interp_path == NULL || | (brand_info->interp_path == NULL || | ||||
strcmp(interp, brand_info->interp_path) == 0)) { | strcmp(interp, brand_info->interp_path) == 0)) { | ||||
error = __elfN(load_file)(imgp->proc, | error = __elfN(load_file)(imgp->proc, | ||||
brand_info->interp_newpath, addr, entry); | brand_info->interp_newpath, addr, entry); | ||||
if (error == 0) | if (error == 0) | ||||
return (0); | return (0); | ||||
▲ Show 20 Lines • Show All 1,831 Lines • Show Last 20 Lines |
this can be avoided if namei() clean ni_vp on error path