aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2026-09-24 16:14:34 +0000
committerMark Johnston <markj@FreeBSD.org>2026-09-24 16:20:25 +0000
commitdd16a5f53b0b2e967d20d2900f18fc320997679b (patch)
treec1b0384c804bb46af146eacd49dc9b8a35422fec
parentc14281f6bb462ca03383d92a0d88228e9426268e (diff)
lockf: Do not block in vfs_busy()
A race is possible otherwise: vfs_busy() may return after an unmounted filesystem has been removed from the global mount list. That is, vfs_busy() will block until vfs_mount_destroy() sets MNTK_REFEXPIRE, and at that point the mountpoint has been removed from the mountlist, so TAILQ_FOREACH can return an invalid value. Simply do not block if the mountpoint is being unmounted. Reviewed by: kib Fixes: eca39864f702 ("Add sysctl KERN_LOCKF") MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D59982
-rw-r--r--sys/kern/kern_lockf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/kern/kern_lockf.c b/sys/kern/kern_lockf.c
index a318c26484b4..2cb02b21cd78 100644
--- a/sys/kern/kern_lockf.c
+++ b/sys/kern/kern_lockf.c
@@ -2558,7 +2558,7 @@ sysctl_kern_lockf_run(struct sbuf *sb)
error = 0;
mtx_lock(&mountlist_mtx);
TAILQ_FOREACH(mp, &mountlist, mnt_list) {
- error = vfs_busy(mp, MBF_MNTLSTLOCK);
+ error = vfs_busy(mp, MBF_MNTLSTLOCK | MBF_NOWAIT);
if (error != 0)
continue;
error = mp->mnt_op->vfs_report_lockf(mp, sb);