Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Nov 2018 19:13:10 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r341256 - head/sys/kern
Message-ID:  <201811291913.wATJDADO016706@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Nov 29 19:13:10 2018
New Revision: 341256
URL: https://svnweb.freebsd.org/changeset/base/341256

Log:
  If BENEATH is specified, always latch the topping directory vnode.
  
  It is possible that we started with a relative path but during the
  lookup, found an absolute symlink.  In this case, BENEATH handling
  code needs the latch, but it is too late to calculate it.
  
  While there, somewhat improve the assertions.  Clear the NI_LCF_LATCH
  flag when the latch vnode is released, so that asserts know the state.
  Assert that there is a latch if we entered beneath+abs path mode,
  after the starting point is processed.
  
  Reported by:	wulf
  With more input from:	pho
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/kern/vfs_lookup.c

Modified: head/sys/kern/vfs_lookup.c
==============================================================================
--- head/sys/kern/vfs_lookup.c	Thu Nov 29 19:11:35 2018	(r341255)
+++ head/sys/kern/vfs_lookup.c	Thu Nov 29 19:13:10 2018	(r341256)
@@ -202,8 +202,10 @@ nameicap_cleanup(struct nameidata *ndp, bool clean_lat
 		vdrop(nt->dp);
 		uma_zfree(nt_zone, nt);
 	}
-	if (clean_latch && (ndp->ni_lcf & NI_LCF_LATCH) != 0)
+	if (clean_latch && (ndp->ni_lcf & NI_LCF_LATCH) != 0) {
+		ndp->ni_lcf &= ~NI_LCF_LATCH;
 		vrele(ndp->ni_beneath_latch);
+	}
 }
 
 /*
@@ -446,7 +448,7 @@ namei(struct nameidata *ndp)
 		if (error == 0 && dp->v_type != VDIR)
 			error = ENOTDIR;
 	}
-	if (error == 0 && (ndp->ni_lcf & NI_LCF_BENEATH_ABS) != 0) {
+	if (error == 0 && (cnp->cn_flags & BENEATH) != 0) {
 		if (ndp->ni_dirfd == AT_FDCWD) {
 			ndp->ni_beneath_latch = fdp->fd_cdir;
 			vrefact(ndp->ni_beneath_latch);
@@ -471,6 +473,8 @@ namei(struct nameidata *ndp)
 			vrele(dp);
 		goto out;
 	}
+	MPASS((ndp->ni_lcf & (NI_LCF_BENEATH_ABS | NI_LCF_LATCH)) !=
+	    NI_LCF_BENEATH_ABS);
 	if (((ndp->ni_lcf & NI_LCF_STRICTRELATIVE) != 0 &&
 	    lookup_cap_dotdot != 0) ||
 	    ((ndp->ni_lcf & NI_LCF_STRICTRELATIVE) == 0 &&



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811291913.wATJDADO016706>