The branch main has been updated by kib:

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

commit c584bb9cac16bc200ac45cc8b709e7e7e99e24bb
Author:     Konstantin Belousov <k...@freebsd.org>
AuthorDate: 2023-09-20 03:42:31 +0000
Commit:     Konstantin Belousov <k...@freebsd.org>
CommitDate: 2023-09-21 00:59:11 +0000

    vfs_remount_ro(): mnt_lockref should be only accessed after vfs_op_enter()
    
    PR:     273953
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 sys/kern/vfs_mount.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 45ab9cfc93cc..8364081585f8 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -3004,6 +3004,7 @@ vfs_remount_ro(struct mount *mp)
        struct vnode *vp_covered, *rootvp;
        int error;
 
+       vfs_op_enter(mp);
        KASSERT(mp->mnt_lockref > 0,
            ("vfs_remount_ro: mp %p is not busied", mp));
        KASSERT((mp->mnt_kern_flag & MNTK_UNMOUNT) == 0,
@@ -3012,17 +3013,19 @@ vfs_remount_ro(struct mount *mp)
        rootvp = NULL;
        vp_covered = mp->mnt_vnodecovered;
        error = vget(vp_covered, LK_EXCLUSIVE | LK_NOWAIT);
-       if (error != 0)
+       if (error != 0) {
+               vfs_op_exit(mp);
                return (error);
+       }
        VI_LOCK(vp_covered);
        if ((vp_covered->v_iflag & VI_MOUNT) != 0) {
                VI_UNLOCK(vp_covered);
                vput(vp_covered);
+               vfs_op_exit(mp);
                return (EBUSY);
        }
        vp_covered->v_iflag |= VI_MOUNT;
        VI_UNLOCK(vp_covered);
-       vfs_op_enter(mp);
        vn_seqc_write_begin(vp_covered);
 
        MNT_ILOCK(mp);

Reply via email to