The branch stable/13 has been updated by mjg:

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

commit 9134711fb5b70effb53bbdc21c79fe3b0c8a67cc
Author:     Kyle Evans <kev...@freebsd.org>
AuthorDate: 2021-08-18 17:31:45 +0000
Commit:     Mateusz Guzik <m...@freebsd.org>
CommitDate: 2021-08-23 12:33:32 +0000

    uipc: avoid circular pr_{slow,fast}timos
    
    domain_init() gets reinvoked for each vnet on a system, so we must not
    alter global state.  Practically speaking, we were creating circular
    lists and tying up a softclock thread into an infinite loop.
    
    The breakage here was most easily observed by simply creating a jail
    in a new vnet and watching the system suddenly become erratic.
    
    Reported by:    markj
    Fixes:  e0a17c3f063f ("uipc: create dedicated lists for fast ...")
    Pointy hat:     kevans
    
    (cherry picked from commit d7e1bdfebacc4de25dc51e14a91d66bb429677c9)
---
 sys/kern/uipc_domain.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c
index 76c0364f6824..4342f1026783 100644
--- a/sys/kern/uipc_domain.c
+++ b/sys/kern/uipc_domain.c
@@ -186,12 +186,23 @@ domain_init(void *arg)
                (*dp->dom_init)();
        for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
                protosw_init(pr);
-               rm_wlock(&pftimo_lock);
-               if (pr->pr_fasttimo != NULL)
-                       LIST_INSERT_HEAD(&pffast_list, pr, pr_fasttimos);
-               if (pr->pr_slowtimo != NULL)
-                       LIST_INSERT_HEAD(&pfslow_list, pr, pr_slowtimos);
-               rm_wunlock(&pftimo_lock);
+
+               /*
+                * Note that with VIMAGE enabled, domain_init() will be
+                * re-invoked for each new vnet that's created.  The below lists
+                * are intended to be system-wide, so avoid altering global
+                * state for non-default vnets.
+                */
+               if (IS_DEFAULT_VNET(curvnet)) {
+                       rm_wlock(&pftimo_lock);
+                       if (pr->pr_fasttimo != NULL)
+                               LIST_INSERT_HEAD(&pffast_list, pr,
+                                   pr_fasttimos);
+                       if (pr->pr_slowtimo != NULL)
+                               LIST_INSERT_HEAD(&pfslow_list, pr,
+                                   pr_slowtimos);
+                       rm_wunlock(&pftimo_lock);
+               }
        }
 
        /*
_______________________________________________
dev-commits-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"

Reply via email to