git: 083608e4669e - stable/13 - UFS: panic rather than forcibly unmount the root fs

From: Chuck Silvers <chs_at_FreeBSD.org>
Date: Wed, 20 Mar 2024 21:25:00 UTC
The branch stable/13 has been updated by chs:

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

commit 083608e4669e0eb3d31d4e7d9ced00ae822807e6
Author:     Chuck Silvers <chs@FreeBSD.org>
AuthorDate: 2023-08-10 16:55:47 +0000
Commit:     Chuck Silvers <chs@FreeBSD.org>
CommitDate: 2024-03-20 20:25:49 +0000

    UFS: panic rather than forcibly unmount the root fs
    
    If the root fs is forcibly unmounted then basically every process
    will die with a SEGV as soon as it tries to run again because libc.so
    is gone, which leaves the system basically hung.  It seems better
    to just panic instead, so let's do that.
    
    PR:             276944
    Requested-by:   karels
    Reviewed-by:    imp, mckusick, karels
    Sponsored-by:   Netflix
    Differential Revision:  https://reviews.freebsd.org/D41387
    
    (cherry picked from commit 60a41168d195cc09f7351c2c2bcafc389ed52406)
---
 sys/ufs/ffs/ffs_vfsops.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index a7c619fe98ef..433df476f563 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -324,6 +324,9 @@ ffs_fsfail_cleanup_locked(struct ufsmount *ump, int error)
 	mtx_assert(UFS_MTX(ump), MA_OWNED);
 	if (error == ENXIO && (ump->um_flags & UM_FSFAIL_CLEANUP) == 0) {
 		ump->um_flags |= UM_FSFAIL_CLEANUP;
+		if (ump->um_mountp == rootvnode->v_mount)
+			panic("UFS: root fs would be forcibly unmounted");
+
 		/*
 		 * Queue an async forced unmount.
 		 */