Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177957856
D62023.1795648285.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D62023.1795648285.diff
View Options
diff --git a/share/man/man4/nullfs.4 b/share/man/man4/nullfs.4
--- a/share/man/man4/nullfs.4
+++ b/share/man/man4/nullfs.4
@@ -22,7 +22,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd March 15, 2022
+.Dd November 22, 2026
.Dt NULLFS 4
.Os
.Sh NAME
@@ -47,6 +47,13 @@
driver will permit the
.Fx
kernel to mount a loopback file system sub-tree.
+A regular file or a socket may be mounted again over a
+.Nm
+vnode of that same object, so a read-write mount of one file can sit
+on a read-only
+.Nm
+of a tree that contains the file.
+A second mount of the same directory is rejected.
.Sh EXAMPLES
To mount a
.Nm
diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c
--- a/sys/fs/nullfs/null_vfsops.c
+++ b/sys/fs/nullfs/null_vfsops.c
@@ -161,10 +161,17 @@
/*
* Check multi null mount to avoid `lock against myself' panic.
+ * A second nullfs of the same directory deadlocks on the shared
+ * lower vnode lock. A regular file or a socket may be mounted
+ * again, so one object can be read-write on a read-only nullfs
+ * of that same object. null_lock() nests that second hold.
*/
if (null_is_nullfs_vnode(mp->mnt_vnodecovered)) {
nn = VTONULL(mp->mnt_vnodecovered);
- if (nn == NULL || lowerrootvp == nn->null_lowervp) {
+ if (nn == NULL ||
+ (lowerrootvp == nn->null_lowervp &&
+ lowerrootvp->v_type != VREG &&
+ lowerrootvp->v_type != VSOCK)) {
NULLFSDEBUG("nullfs_mount: multi null mount?\n");
vput(lowerrootvp);
return (EDEADLK);
diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c
--- a/sys/fs/nullfs/null_vnops.c
+++ b/sys/fs/nullfs/null_vnops.c
@@ -857,7 +857,16 @@
return (vop_stdlock(ap));
VNPASS(lvp->v_holdcnt > 0, lvp);
- error = VOP_LOCK(lvp, ap->a_flags);
+ /*
+ * Stacking a file or socket nullfs on a nullfs vnode of that
+ * same object locks the lower vnode twice on one thread. Nest
+ * that hold. Leave ap->a_flags alone; the doomed path below
+ * still reads it.
+ */
+ flags = ap->a_flags;
+ if (VOP_ISLOCKED(lvp) != 0)
+ flags |= LK_CANRECURSE;
+ error = VOP_LOCK(lvp, flags);
/*
* We might have slept to get the lock and someone might have
* clean our vnode already, switching vnode lock from one in
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 25, 11:11 PM (19 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42001217
Default Alt Text
D62023.1795648285.diff (2 KB)
Attached To
Mode
D62023: nullfs: Allow a file or socket to be mounted again
Attached
Detach File
Event Timeline