git: 47039ba1e03b - stable/13 - Don't allow stacking of file mounts

From: Doug Rabson <dfr_at_FreeBSD.org>
Date: Fri, 06 Jan 2023 09:46:35 UTC
The branch stable/13 has been updated by dfr:

URL: https://cgit.FreeBSD.org/src/commit/?id=47039ba1e03b047e313f8f9d1d42ef89c0616163

commit 47039ba1e03b047e313f8f9d1d42ef89c0616163
Author:     Doug Rabson <dfr@FreeBSD.org>
AuthorDate: 2022-12-06 13:24:55 +0000
Commit:     Doug Rabson <dfr@FreeBSD.org>
CommitDate: 2023-01-06 07:57:57 +0000

    Don't allow stacking of file mounts
    
    Reviewed by:    mjg, kib
    Tested by:      pho
    
    (cherry picked from commit 71e9be1bd54cf54de6fa273af71468e790ccdf47)
---
 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 e6bb6036a5a0..21e60c9e74d1 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -1392,6 +1392,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) {