Date: Mon, 23 Aug 2021 12:34:33 GMT From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 9134711fb5b7 - stable/13 - uipc: avoid circular pr_{slow, fast}timos Message-ID: <202108231234.17NCYXgJ023194@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=9134711fb5b70effb53bbdc21c79fe3b0c8a67cc commit 9134711fb5b70effb53bbdc21c79fe3b0c8a67cc Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2021-08-18 17:31:45 +0000 Commit: Mateusz Guzik <mjg@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); + } } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108231234.17NCYXgJ023194>