Page MenuHomeFreeBSD

fix panic when VFS_FSSTAT() fails during an NFS mount
ClosedPublic

Authored by rmacklem on Aug 23 2020, 4:10 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 23, 11:00 AM
Unknown Object (File)
Wed, Apr 17, 5:55 AM
Unknown Object (File)
Dec 20 2023, 8:29 AM
Unknown Object (File)
Oct 30 2023, 12:22 AM
Unknown Object (File)
Jun 28 2023, 12:21 AM
Unknown Object (File)
Jun 28 2023, 12:21 AM
Unknown Object (File)
Jun 28 2023, 12:20 AM
Unknown Object (File)
Jun 28 2023, 12:19 AM
Subscribers

Details

Summary

If VFS_STATFS() fails during an NFS mount, there is a panic

v_seqc_users == 0 not met

This patch fixes it.
(I seems to make sense, but I know nothing about the v_seqc_users
stuff.)

Test Plan

Tested by doing an NFS mount attempt where the VFS_STATFS()
will fail, due to the exports settings on the NFS server.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I think this should go in as it is, but a helper for cleaning this up would be nice. I'll probably refactor this a little bit later.

This revision is now accepted and ready to land.Aug 23 2020, 5:34 AM

Actually better would be something in these lines:

diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 84d14fadae1..dbafd0d363d 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -969,11 +969,14 @@ vfs_domount_first(
        if ((error = VFS_MOUNT(mp)) != 0 ||
            (error1 = VFS_STATFS(mp, &mp->mnt_stat)) != 0 ||
            (error1 = VFS_ROOT(mp, LK_EXCLUSIVE, &newdp)) != 0) {
+               rootvp = NULL;
                if (error1 != 0) {
                        error = error1;
                        rootvp = vfs_cache_root_clear(mp);
-                       if (rootvp != NULL)
+                       if (rootvp != NULL) {
+                               vhold(rotvp);
                                vrele(rootvp);
+                       }
                        if ((error1 = VFS_UNMOUNT(mp, 0)) != 0)
                                printf("VFS_UNMOUNT returned %d\n", error1);
                }
@@ -983,6 +986,10 @@ vfs_domount_first(
                VI_LOCK(vp);
                vp->v_iflag &= ~VI_MOUNT;
                VI_UNLOCK(vp);
+               if (rootvp != NULL) {
+                       vn_seqc_write_end(rootvp);
+                       vdrop(rootvp);
+               }
                vn_seqc_write_end(vp);
                vrele(vp);
                return (error);

The point is that we want to keep the thing in a "flux" state until the mount is fully decommissioned.

Update the patch as suggested by mjg@.

This revision now requires review to proceed.Aug 24 2020, 2:05 AM
This revision is now accepted and ready to land.Aug 24 2020, 2:40 AM