diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -130,6 +130,12 @@ unsigned new; }; +/* + * Handle jail teardown in a dedicated thread to avoid deadlocks from + * vnet_destroy(). + */ +TASKQUEUE_DEFINE_THREAD(jail_remove); + /* allprison, allprison_racct and lastprid are protected by allprison_lock. */ struct sx allprison_lock; SX_SYSINIT(allprison_lock, &allprison_lock, "allprison"); @@ -2902,7 +2908,7 @@ * Don't remove the last reference in this context, * in case there are locks held. */ - taskqueue_enqueue(taskqueue_thread, &pr->pr_task); + taskqueue_enqueue(taskqueue_jail_remove, &pr->pr_task); } } @@ -2976,7 +2982,7 @@ pr->pr_id)); pr->pr_flags |= PR_COMPLETE_PROC; mtx_unlock(&pr->pr_mtx); - taskqueue_enqueue(taskqueue_thread, &pr->pr_task); + taskqueue_enqueue(taskqueue_jail_remove, &pr->pr_task); } }