NetBSD Problem Report #56397
From www@netbsd.org Sat Sep 11 10:46:29 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 906761A923A
for <gnats-bugs@gnats.NetBSD.org>; Sat, 11 Sep 2021 10:46:29 +0000 (UTC)
Message-Id: <20210911104628.3C3731A923B@mollari.NetBSD.org>
Date: Sat, 11 Sep 2021 10:46:28 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: Lock order reversal in dtrace: dtrace_provider_lock <-> kernconfig_lock
X-Send-Pr-Version: www-1.0
>Number: 56397
>Category: kern
>Synopsis: Lock order reversal in dtrace: dtrace_provider_lock <-> kernconfig_lock
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Sep 11 10:50:00 +0000 2021
>Originator: Taylor R Campbell
>Release: HEAD
>Organization:
The NutBSD Foodation
>Environment:
slowly roasting in a fog of CO2
>Description:
kernconfig_lock -> dtrace_provider_lock:
1. The dtrace module registers a module load callback dtrace_module_loaded.
2. kern_module.c holds kernconfig_lock while it calls module callbacks, including dtrace_module_loaded.
3. dtrace_module_loaded takes dtrace_provider_lock.
dtrace_provider_lock -> kernconfig_lock:
1. dtrace_open (open of /dev/dtrace/dtrace) takes dtrace_provider_lock.
2. dtrace_open calls dtrace_probe_provide.
3. dtrace_probe_provide takes kernconfig_lock.
>How-To-Repeat:
concurrent modload, modunload, and dtrace
>Fix:
Reverse one of the lock orders. Maybe hoist the kernconfig_lock out of dtrace_probe_provide into the caller, but this requires adjusting dtrace_enabling_provide, which requires taking kernconfig_lock on every dtrace_register. Maybe that's OK.
(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.