64c563
commit 710a492fda68092a02d6360d7a185f6a4dcaea85
64c563
Author: NeilBrown <neilb@suse.de>
64c563
Date:   Thu Feb 26 14:10:35 2015 -0500
64c563
64c563
    exports.man: improve documentation of 'nohide' and 'crossmnt'
64c563
    
64c563
    - note that 'nohide' is irrelevant for NFSv4
64c563
    - note that children on a 'crossmnt' filesystem cannot be unexported
64c563
    - note that 'nocrossmnt' is a valid option, but probably not useful.
64c563
    
64c563
    Signed-off-by: NeilBrown <neilb@suse.de>
64c563
    Signed-off-by: Steve Dickson <steved@redhat.com>
64c563
64c563
diff --git a/utils/exportfs/exports.man b/utils/exportfs/exports.man
64c563
index 59358e6..9309246 100644
64c563
--- a/utils/exportfs/exports.man
64c563
+++ b/utils/exportfs/exports.man
64c563
@@ -218,16 +218,46 @@ This option can be very useful in some situations, but it should be
64c563
 used with due care, and only after confirming that the client system
64c563
 copes with the situation effectively.
64c563
 
64c563
-The option can be explicitly disabled with
64c563
+The option can be explicitly disabled for NFSv2 and NFSv3 with
64c563
 .IR hide .
64c563
+
64c563
+This option is not relevant when NFSv4 is use.  NFSv4 never hides
64c563
+subordinate filesystems.  Any filesystem that is exported will be
64c563
+visible where expected when using NFSv4.
64c563
 .TP
64c563
-.IR crossmnt
64c563
+.I crossmnt
64c563
 This option is similar to
64c563
 .I nohide
64c563
-but it makes it possible for clients to move from the filesystem marked
64c563
-with crossmnt to exported filesystems mounted on it.  Thus when a child
64c563
-filesystem "B" is mounted on a parent "A", setting crossmnt on "A" has
64c563
-the same effect as setting "nohide" on B.
64c563
+but it makes it possible for clients to access all filesystems mounted
64c563
+on a filesystem marked with
64c563
+.IR crossmnt .
64c563
+Thus when a child filesystem "B" is mounted on a parent "A", setting
64c563
+crossmnt on "A" has a similar effect to setting "nohide" on B.
64c563
+
64c563
+With
64c563
+.I nohide
64c563
+the child filesystem needs to be explicitly exported.  With
64c563
+.I crossmnt
64c563
+it need not.  If a child of a
64c563
+.I crossmnt
64c563
+file is not explicitly exported, then it will be implicitly exported
64c563
+with the same export options as the parent, except for
64c563
+.IR fsid= .
64c563
+This makes it impossible to
64c563
+.B not
64c563
+export a child of a
64c563
+.I crossmnt
64c563
+filesystem.  If some but not all subordinate filesystems of a parent
64c563
+are to be exported, then they must be explicitly exported and the
64c563
+parent should not have
64c563
+.I crossmnt
64c563
+set.
64c563
+
64c563
+The
64c563
+.I nocrossmnt
64c563
+option can explictly disable
64c563
+.I crossmnt
64c563
+if it was previously set.  This is rarely useful.
64c563
 .TP
64c563
 .IR no_subtree_check
64c563
 This option disables subtree checking, which has mild security
64c563
64c563
commit b7341b19d62481504f1820414159009535d37809
64c563
Author: NeilBrown <neilb@suse.de>
64c563
Date:   Wed Feb 25 16:47:56 2015 -0500
64c563
64c563
    mountd: fix next_mnt handling for "/"
64c563
    
64c563
    If the (exported) path passed to next_mnt() is simply "/", next_mnt()
64c563
    will not report any children, as none start with "/" followed by a '/'.
64c563
    So make a special case for strlen(p)==1.  In that case, return all
64c563
    children.
64c563
    
64c563
    This gives correct handling if only "/" is exported.
64c563
    
64c563
    Signed-off-by: NeilBrown <neilb@suse.de>
64c563
    Signed-off-by: Steve Dickson <steved@redhat.com>
64c563
64c563
diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
64c563
index 1430aee..23af4a9 100644
64c563
--- a/utils/mountd/cache.c
64c563
+++ b/utils/mountd/cache.c
64c563
@@ -365,7 +365,7 @@ static char *next_mnt(void **v, char *p)
64c563
 		*v = f;
64c563
 	} else
64c563
 		f = *v;
64c563
-	while ((me = getmntent(f)) != NULL &&
64c563
+	while ((me = getmntent(f)) != NULL && l > 1 &&
64c563
 	       (strncmp(me->mnt_dir, p, l) != 0 ||
64c563
 		me->mnt_dir[l] != '/'))
64c563
 		;
64c563
64c563
commit 7e27d4a542bf97e0ddc1036010e1b2d218a01c2b
64c563
Author: Vivek Trivedi <t.vivek@samsung.com>
64c563
Date:   Wed Sep 16 11:14:03 2015 -0400
64c563
64c563
    mountd: fix mount issue due to comparison with uninitialized uuid
64c563
    
64c563
    Fix mount issue due to comparison of uninitialized variable
64c563
    u(uuid) with parsed->fhuuid when uuid_by_path return 0.
64c563
    
64c563
    /tmp/usb
64c563
    192.168.1.0/16(ro,no_root_squash,no_subtree_check,fsid=0)
64c563
    /tmp/usb/sda1       192.168.1.0/16(ro,no_root_squash,no_subtree_check)
64c563
    /tmp/usb/sdb1       192.168.1.0/16(ro,no_root_squash,no_subtree_check)
64c563
    
64c563
    mount -t nfs -o nolock,nfsvers=3 192.168.1.2:/tmp/usb/sda1 /tmp/sda1
64c563
    mount -t nfs -o nolock,nfsvers=3 192.168.1.2:/tmp/usb/sdb1 /tmp/sdb1
64c563
    
64c563
    results in below mountd error:
64c563
    mountd: /tmp/usb and /tmp/usb/sdb1 have same filehandle for
64c563
    192.168.1.0/16, using first
64c563
    
64c563
    when uuid_by_path returned 0, by chance, garbage value of u was same as
64c563
    parsed->fhuuid(of sdb1), and comparison of these resulted in above
64c563
    error.
64c563
    
64c563
    Signed-off-by: Vivek Trivedi <t.vivek@samsung.com>
64c563
    Reviewed-by: Amit Sahrawat <a.sahrawat@samsung.com>
64c563
    Signed-off-by: Steve Dickson <steved@redhat.com>
64c563
64c563
diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
64c563
index 9a1bb27..1430aee 100644
64c563
--- a/utils/mountd/cache.c
64c563
+++ b/utils/mountd/cache.c
64c563
@@ -547,18 +547,17 @@ static bool match_fsid(struct parsed_fsid *parsed, nfs_export *exp, char *path)
64c563
 		if (!is_mountpoint(path))
64c563
 			return false;
64c563
 	check_uuid:
64c563
-		if (exp->m_export.e_uuid)
64c563
+		if (exp->m_export.e_uuid) {
64c563
 			get_uuid(exp->m_export.e_uuid, parsed->uuidlen, u);
64c563
+			if (memcmp(u, parsed->fhuuid, parsed->uuidlen) == 0)
64c563
+				return true;
64c563
+		}
64c563
 		else
64c563
 			for (type = 0;
64c563
 			     uuid_by_path(path, type, parsed->uuidlen, u);
64c563
 			     type++)
64c563
 				if (memcmp(u, parsed->fhuuid, parsed->uuidlen) == 0)
64c563
 					return true;
64c563
-
64c563
-		if (memcmp(u, parsed->fhuuid, parsed->uuidlen) != 0)
64c563
-			return false;
64c563
-		return true;
64c563
 	}
64c563
 	/* Well, unreachable, actually: */
64c563
 	return false;