aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2026-05-16 22:16:45 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2026-05-17 19:44:06 +0000
commit7bdf2b5d5fbabfc8749c4ff6e618c3e843b14de0 (patch)
treec8c769e95e2cd2938027ec30b53de540887bdc1c
parent363ea40c765424b3cbd9b96790235af030fcc8ff (diff)
nullfs: do not allow to mount a vnode over itself
This causes recursion in VFS that is not worth handling. PR: 275570 Reported by: Alex S <iwtcex@gmail.com> Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D57043
-rw-r--r--sys/fs/nullfs/null_vfsops.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c
index c3eec727aeea..0ec4f9c87297 100644
--- a/sys/fs/nullfs/null_vfsops.c
+++ b/sys/fs/nullfs/null_vfsops.c
@@ -152,6 +152,14 @@ nullfs_mount(struct mount *mp)
lowerrootvp = ndp->ni_vp;
/*
+ * Do not allow to mount a vnode over itself.
+ */
+ if (mp->mnt_vnodecovered == lowerrootvp) {
+ vput(lowerrootvp);
+ return (EDEADLK);
+ }
+
+ /*
* Check multi null mount to avoid `lock against myself' panic.
*/
if (null_is_nullfs_vnode(mp->mnt_vnodecovered)) {