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