Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_lookup.c
Show First 20 Lines • Show All 236 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static int | static int | ||||
namei_handle_root(struct nameidata *ndp, struct vnode **dpp) | namei_handle_root(struct nameidata *ndp, struct vnode **dpp) | ||||
{ | { | ||||
struct componentname *cnp; | struct componentname *cnp; | ||||
cnp = &ndp->ni_cnd; | cnp = &ndp->ni_cnd; | ||||
if ((ndp->ni_lcf & NI_LCF_STRICTRELATIVE) != 0) { | if ((ndp->ni_lcf & NI_LCF_STRICTRELATIVE) != 0) { | ||||
jonathan: Would it be sensible to instead use `cn_flags & BENEATH` as a reason to set… | |||||
Done Inline ActionsI am not completely sure what is your suggestion there, but I can provide some explanation why the current patch is structured as it is. I ended up disabling absolute paths for O_BENEATH, according to jilles' suggestion, for the immediate commit. My plan is to allow absolute paths, assuming that the tail of the path descends into cwd and does not leave it (I hope the idea is clear, I will try to word it more comprehensibly when I implement it). This mode is only relevant for BENEATH and not for STRICTRELATIVE AKA cap mode, for obvious reasons. So I want to test for BENEATH where it is actually BENEATH mode. kib: I am not completely sure what is your suggestion there, but I can provide some explanation why… | |||||
#ifdef KTRACE | #ifdef KTRACE | ||||
if (KTRPOINT(curthread, KTR_CAPFAIL)) | if (KTRPOINT(curthread, KTR_CAPFAIL)) | ||||
ktrcapfail(CAPFAIL_LOOKUP, NULL, NULL); | ktrcapfail(CAPFAIL_LOOKUP, NULL, NULL); | ||||
#endif | #endif | ||||
return (ENOTCAPABLE); | return (ENOTCAPABLE); | ||||
} | } | ||||
while (*(cnp->cn_nameptr) == '/') { | while (*(cnp->cn_nameptr) == '/') { | ||||
cnp->cn_nameptr++; | cnp->cn_nameptr++; | ||||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | #endif | ||||
FILEDESC_SUNLOCK(fdp); | FILEDESC_SUNLOCK(fdp); | ||||
if (ndp->ni_startdir != NULL && !startdir_used) | if (ndp->ni_startdir != NULL && !startdir_used) | ||||
vrele(ndp->ni_startdir); | vrele(ndp->ni_startdir); | ||||
if (error != 0) { | if (error != 0) { | ||||
if (dp != NULL) | if (dp != NULL) | ||||
vrele(dp); | vrele(dp); | ||||
goto out; | goto out; | ||||
} | } | ||||
if ((ndp->ni_lcf & NI_LCF_STRICTRELATIVE) != 0 && | if (((ndp->ni_lcf & NI_LCF_STRICTRELATIVE) != 0 && | ||||
lookup_cap_dotdot != 0) | lookup_cap_dotdot != 0) || | ||||
((ndp->ni_lcf & NI_LCF_STRICTRELATIVE) == 0 && | |||||
(cnp->cn_flags & BENEATH) != 0)) | |||||
ndp->ni_lcf |= NI_LCF_CAP_DOTDOT; | ndp->ni_lcf |= NI_LCF_CAP_DOTDOT; | ||||
SDT_PROBE3(vfs, namei, lookup, entry, dp, cnp->cn_pnbuf, | SDT_PROBE3(vfs, namei, lookup, entry, dp, cnp->cn_pnbuf, | ||||
cnp->cn_flags); | cnp->cn_flags); | ||||
for (;;) { | for (;;) { | ||||
ndp->ni_startdir = dp; | ndp->ni_startdir = dp; | ||||
error = lookup(ndp); | error = lookup(ndp); | ||||
if (error != 0) | if (error != 0) | ||||
goto out; | goto out; | ||||
▲ Show 20 Lines • Show All 982 Lines • Show Last 20 Lines |
Would it be sensible to instead use cn_flags & BENEATH as a reason to set NI_LCF_STRICTRELATIVE? That might then avoid some of the duplicate logic...