NetBSD Problem Report #56405

From www@netbsd.org  Wed Sep 15 23:04:44 2021
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 0F58F1A921F
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 15 Sep 2021 23:04:44 +0000 (UTC)
Message-Id: <20210915230442.AFE471A923A@mollari.NetBSD.org>
Date: Wed, 15 Sep 2021 23:04:42 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: kthread_join is busted
X-Send-Pr-Version: www-1.0

>Number:         56405
>Category:       kern
>Synopsis:       kthread_join is busted
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 15 23:05:00 +0000 2021
>Originator:     Taylor R Campbel
>Release:        every release since it was introduced ever
>Organization:
Teh NteBDS Fuondatoin
>Environment:
>Description:
If thread A issues kthread_join(B), and while it waits thread B issues kthread_join(C), then the threads deadlock.

This happens because:

1. When thread A calls kthread_join(B), it sets kthread_jtarget = B and waits for B to acknowledge exiting.
2. When thread B calls kthread_join(C), it waits until kthread_target is null before doing the same.
3. Thread C never gets to wake thread B because thread B is waiting for thread A to quit hogging kthread_jtarget and thread A is waiting for thread B to exit before it will relinquish kthread_jtarget.
>How-To-Repeat:
try to use kthread_join as documented, trip over own shoelaces
>Fix:
Yes, please!

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.