diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -422,10 +422,10 @@ cnp->cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK); if (ndp->ni_segflg == UIO_SYSSPACE) { error = copystr(ndp->ni_dirp, cnp->cn_pnbuf, MAXPATHLEN, - &ndp->ni_pathlen); + &ndp->ni_orig_pathlen); } else { error = copyinstr(ndp->ni_dirp, cnp->cn_pnbuf, MAXPATHLEN, - &ndp->ni_pathlen); + &ndp->ni_orig_pathlen); } return (error); @@ -606,11 +606,6 @@ MPASS(ndp->ni_startdir == NULL || ndp->ni_startdir->v_type == VDIR || ndp->ni_startdir->v_type == VBAD); -restart: - ndp->ni_lcf = 0; - ndp->ni_loopcnt = 0; - ndp->ni_vp = NULL; - error = namei_getpath(ndp); if (__predict_false(error != 0)) { namei_cleanup_cnp(cnp); @@ -619,7 +614,12 @@ return (error); } +restart: + ndp->ni_lcf = 0; + ndp->ni_loopcnt = 0; + ndp->ni_vp = NULL; cnp->cn_nameptr = cnp->cn_pnbuf; + ndp->ni_pathlen = ndp->ni_orig_pathlen; #ifdef KTRACE if (KTRPOINT(td, KTR_NAMEI)) { @@ -643,7 +643,6 @@ NDVALIDATE(ndp); else if (__predict_false(pwd->pwd_adir != pwd->pwd_rdir && (cnp->cn_flags & ISRESTARTED) == 0)) { - namei_cleanup_cnp(cnp); NDRESTART(ndp); goto restart; } @@ -693,7 +692,6 @@ (cnp->cn_flags & ISRESTARTED) == 0)) { nameicap_cleanup(ndp); pwd_drop(pwd); - namei_cleanup_cnp(cnp); NDRESTART(ndp); goto restart; } else diff --git a/sys/sys/namei.h b/sys/sys/namei.h --- a/sys/sys/namei.h +++ b/sys/sys/namei.h @@ -101,6 +101,7 @@ * Shared between namei and lookup/commit routines. */ u_short ni_loopcnt; /* count of symlinks encountered */ + size_t ni_orig_pathlen; /* original chars in path */ size_t ni_pathlen; /* remaining chars in path */ char *ni_next; /* next location in pathname */ /*