git: 71e9be1bd54c - main - Don't allow stacking of file mounts

From: Doug Rabson <dfr_at_FreeBSD.org>
Date: Mon, 19 Dec 2022 16:50:35 UTC
The branch main has been updated by dfr:

URL: https://cgit.FreeBSD.org/src/commit/?id=71e9be1bd54cf54de6fa273af71468e790ccdf47

commit 71e9be1bd54cf54de6fa273af71468e790ccdf47
Author:     Doug Rabson <dfr@FreeBSD.org>
AuthorDate: 2022-12-06 13:24:55 +0000
Commit:     Doug Rabson <dfr@FreeBSD.org>
CommitDate: 2022-12-19 16:46:27 +0000

    Don't allow stacking of file mounts
    
    Reviewed by:    mjg, kib
    Tested by:      pho
---
 sys/kern/vfs_mount.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 8de9d3c4fff8..67a72f095786 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -1551,6 +1551,12 @@ vfs_domount(
 	if (error != 0)
 		return (error);
 	vp = nd.ni_vp;
+	/*
+	 * Don't allow stacking file mounts to work around problems with the way
+	 * that namei sets nd.ni_dvp to vp_crossmp for these.
+	 */
+	if (vp->v_type == VREG)
+		fsflags |= MNT_NOCOVER;
 	if ((fsflags & MNT_UPDATE) == 0) {
 		if ((vp->v_vflag & VV_ROOT) != 0 &&
 		    (fsflags & MNT_NOCOVER) != 0) {