Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/imgact_elf.c
Show First 20 Lines • Show All 785 Lines • ▼ Show 20 Lines | struct { | ||||
struct vattr attr; | struct vattr attr; | ||||
struct image_params image_params; | struct image_params image_params; | ||||
} *tempdata; | } *tempdata; | ||||
const Elf_Ehdr *hdr = NULL; | const Elf_Ehdr *hdr = NULL; | ||||
const Elf_Phdr *phdr = NULL; | const Elf_Phdr *phdr = NULL; | ||||
struct nameidata *nd; | struct nameidata *nd; | ||||
struct vattr *attr; | struct vattr *attr; | ||||
struct image_params *imgp; | struct image_params *imgp; | ||||
uint64_t nd_flags; | |||||
u_long rbase; | u_long rbase; | ||||
u_long base_addr = 0; | u_long base_addr = 0; | ||||
int error; | int error; | ||||
#ifdef CAPABILITY_MODE | #ifdef CAPABILITY_MODE | ||||
/* | /* | ||||
* XXXJA: This check can go away once we are sufficiently confident | * XXXJA: This check can go away once we are sufficiently confident | ||||
* that the checks in namei() are correct. | * that the checks in namei() are correct. | ||||
*/ | */ | ||||
if (IN_CAPABILITY_MODE(curthread)) | if (IN_CAPABILITY_MODE(curthread)) | ||||
return (ECAPMODE); | return (ECAPMODE); | ||||
#endif | #endif | ||||
tempdata = malloc(sizeof(*tempdata), M_TEMP, M_WAITOK | M_ZERO); | tempdata = malloc(sizeof(*tempdata), M_TEMP, M_WAITOK | M_ZERO); | ||||
nd = &tempdata->nd; | nd = &tempdata->nd; | ||||
attr = &tempdata->attr; | attr = &tempdata->attr; | ||||
imgp = &tempdata->image_params; | imgp = &tempdata->image_params; | ||||
/* | /* | ||||
* Initialize part of the common data | * Initialize part of the common data | ||||
*/ | */ | ||||
imgp->proc = p; | imgp->proc = p; | ||||
imgp->attr = attr; | imgp->attr = attr; | ||||
NDINIT(nd, LOOKUP, ISOPEN | FOLLOW | LOCKSHARED | LOCKLEAF, | nd_flags = ISOPEN | FOLLOW | LOCKSHARED | LOCKLEAF; | ||||
UIO_SYSSPACE, file); | |||||
NDINIT(nd, LOOKUP, nd_flags, UIO_SYSSPACE, file); | |||||
if ((error = namei(nd)) != 0) { | if ((error = namei(nd)) != 0) { | ||||
if (__predict_false(SV_PROC_FLAG(p, SV_WANTABIPATH) != 0)) { | |||||
nd_flags |= WANTABIPATH; | |||||
NDINIT_ABI(nd, LOOKUP, nd_flags, UIO_SYSSPACE, file, p); | |||||
if ((error = namei(nd)) != 0) { | |||||
nd->ni_vp = NULL; | nd->ni_vp = NULL; | ||||
dchagin: this can be avoided if namei() clean ni_vp on error path | |||||
goto fail; | goto fail; | ||||
} | |||||
} else { | |||||
nd->ni_vp = NULL; | |||||
goto fail; | |||||
} | |||||
} | } | ||||
NDFREE_PNBUF(nd); | NDFREE_PNBUF(nd); | ||||
imgp->vp = nd->ni_vp; | imgp->vp = nd->ni_vp; | ||||
/* | /* | ||||
* 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); | ||||
▲ Show 20 Lines • Show All 2,093 Lines • Show Last 20 Lines |
this can be avoided if namei() clean ni_vp on error path