From owner-freebsd-bugs@FreeBSD.ORG Fri Oct 29 22:40:36 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BE26816A4CE for ; Fri, 29 Oct 2004 22:40:36 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5E09A43D6B for ; Fri, 29 Oct 2004 22:40:36 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i9TMeTI2013765 for ; Fri, 29 Oct 2004 22:40:29 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i9TMeTAd013763; Fri, 29 Oct 2004 22:40:29 GMT (envelope-from gnats) Resent-Date: Fri, 29 Oct 2004 22:40:29 GMT Resent-Message-Id: <200410292240.i9TMeTAd013763@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Frank Mayhar Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B6AC516A4CE for ; Fri, 29 Oct 2004 22:33:24 +0000 (GMT) Received: from tinker.exit.com (tinker.exit.com [206.223.0.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 310BE43D2D for ; Fri, 29 Oct 2004 22:33:24 +0000 (GMT) (envelope-from frank@lap.exit.com) Received: from lap.exit.com (lap.exit.com [206.223.0.35]) by tinker.exit.com (8.13.1/8.12.9) with ESMTP id i9TMawFj079503 for ; Fri, 29 Oct 2004 15:36:58 -0700 (PDT) (envelope-from frank@lap.exit.com) Received: from lap.exit.com (localhost [127.0.0.1]) by lap.exit.com (8.13.1/8.13.1) with ESMTP id i9TMWcSf000748 for ; Fri, 29 Oct 2004 15:32:38 -0700 (PDT) (envelope-from frank@lap.exit.com) Received: (from frank@localhost) by lap.exit.com (8.13.1/8.13.1/Submit) id i9TMWcZr000747; Fri, 29 Oct 2004 15:32:38 -0700 (PDT) (envelope-from frank) Message-Id: <200410292232.i9TMWcZr000747@lap.exit.com> Date: Fri, 29 Oct 2004 15:32:38 -0700 (PDT) From: Frank Mayhar To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/73295: Lock order reversal in USB code. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Frank Mayhar List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Oct 2004 22:40:37 -0000 >Number: 73295 >Category: kern >Synopsis: Lock order reversal in USB code. >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Oct 29 22:40:29 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Frank Mayhar >Release: FreeBSD 5.3-STABLE i386 >Organization: Exit Consulting >Environment: System: FreeBSD lap 5.3-STABLE FreeBSD 5.3-STABLE #6: Wed Oct 27 18:08:57 PDT 2004 frank@lap:/home/obj/usr/src/sys/AUTON i386 This is with a kernel built with INVARIANTS, WITNESS and DIAGNOSTIC. I just plugged in the USB device (a SanDisk CF reader) and got the LOR: usb3: handing over full speed device on port 3 to usb1 uhub3: port 3, device disappeared after reset usb3: handing over full speed device on port 3 to usb1 uhub3: port 3, device disappeared after reset umass0: SanDisk Corporation ImageMate CompactFlash USB, rev 1.10/0.09, addr 2 umass0: Get Max Lun not supported (STALLED) malloc(M_WAITOK) of "1024", forcing M_NOWAIT with the following non-sleepable locks held: exclusive sleep mutex dont_sleep_in_callout r = 0 (0xc06c90c0) locked @ /usr/src/sys/kern/kern_timeout.c:257 KDB: enter: witness_warn [thread 100032] Stopped at kdb_enter+0x2b: nop db> trace kdb_enter(c0642e36) at kdb_enter+0x2b witness_warn(5,0,c06788ac,c066347d,c0665fbd) at witness_warn+0x181 uma_zalloc_arg(c1433b00,0,2) at uma_zalloc_arg+0x41 malloc(260,c0693360,2,101,0) at malloc+0xb2 umass_cam_rescan(c218eb00,c06c90c0,0,c0665fbd,101) at umass_cam_rescan+0x1c softclock(0) at softclock+0x1af ithread_loop(c1d8fc80,d55e8d48,c1d8fc80,c04e6160,0) at ithread_loop+0x124 fork_exit(c04e6160,c1d8fc80,d55e8d48) at fork_exit+0xa4 fork_trampoline() at fork_trampoline+0x8 --- trap 0x1, eip = 0, esp = 0xd55e8d7c, ebp = 0 --- It's pretty clear that umass_cam_rescan should be calling malloc with M_NOWAIT rather than M_WAITOK (and, of course, handling the potential error return), or alternatively that the rescan should happen in a sleepable context. >Description: >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: