Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Mar 2008 21:10:03 GMT
From:      Andriy Gapon <avg@icyb.net.ua>
To:        freebsd-emulation@FreeBSD.org
Subject:   Re: kern/73777: [linux] [patch] linux emulation: root dir special handling useless and harmful
Message-ID:  <200803032110.m23LA3eb075720@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/73777; it has been noted by GNATS.

From: Andriy Gapon <avg@icyb.net.ua>
To: bug-followup@FreeBSD.org
Cc: Alexander Leidinger <Alexander@leidinger.net>
Subject: Re: kern/73777: [linux] [patch] linux emulation: root dir special
 handling useless and harmful
Date: Mon, 03 Mar 2008 22:14:40 +0200

 This is a multi-part message in MIME format.
 --------------050001090401010706020209
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 7bit
 
 
 An updated patch that makes the proposed behavior controlled by sysctl.
 Present behavior is the default.
 
 
 -- 
 Andriy Gapon
 
 --------------050001090401010706020209
 Content-Type: text/x-patch;
  name="rootdir-7.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="rootdir-7.patch"
 
 --- sys/kern/vfs_lookup.c.orig	2007-09-21 13:16:56.000000000 +0300
 +++ sys/kern/vfs_lookup.c	2008-03-03 22:03:16.000000000 +0200
 @@ -96,6 +96,11 @@
  SYSCTL_INT(_vfs, OID_AUTO, lookup_shared, CTLFLAG_RW, &lookup_shared, 0,
      "Enables/Disables shared locks for path name translation");
  
 +static int alt_root_is_real_root = 1;
 +SYSCTL_INT(_vfs, OID_AUTO, alt_root_is_real_root, CTLFLAG_RW,
 +    &alt_root_is_real_root, 0,
 +    "Alternative/emulation root directory resolves to the real root");
 +
  /*
   * Convert a pathname into a pointer to a locked vnode.
   *
 @@ -1071,26 +1076,28 @@
  		if (error != 0)
  			goto keeporig;
  
 -		/*
 -		 * We now compare the vnode of the prefix to the one
 -		 * vnode asked. If they resolve to be the same, then we
 -		 * ignore the match so that the real root gets used.
 -		 * This avoids the problem of traversing "../.." to find the
 -		 * root directory and never finding it, because "/" resolves
 -		 * to the emulation root directory. This is expensive :-(
 -		 */
 -		NDINIT(&ndroot, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, prefix,
 -		    td);
 -
 -		/* We shouldn't ever get an error from this namei(). */
 -		error = namei(&ndroot);
 -		if (error == 0) {
 -			if (nd.ni_vp == ndroot.ni_vp)
 -				error = ENOENT;
 -
 -			NDFREE(&ndroot, NDF_ONLY_PNBUF);
 -			vrele(ndroot.ni_vp);
 -			VFS_UNLOCK_GIANT(NDHASGIANT(&ndroot));
 +		if (alt_root_is_real_root) {
 +			/*
 +			 * We now compare the vnode of the prefix to the one
 +			 * vnode asked. If they resolve to be the same, then we
 +			 * ignore the match so that the real root gets used.
 +			 * This avoids the problem of traversing "../.." to find the
 +			 * root directory and never finding it, because "/" resolves
 +			 * to the emulation root directory. This is expensive :-(
 +			 */
 +			NDINIT(&ndroot, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, prefix,
 +			    td);
 +
 +			/* We shouldn't ever get an error from this namei(). */
 +			error = namei(&ndroot);
 +			if (error == 0) {
 +				if (nd.ni_vp == ndroot.ni_vp)
 +					error = ENOENT;
 +
 +				NDFREE(&ndroot, NDF_ONLY_PNBUF);
 +				vrele(ndroot.ni_vp);
 +				VFS_UNLOCK_GIANT(NDHASGIANT(&ndroot));
 +			}
  		}
  	}
  
 
 --------------050001090401010706020209--



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