NetBSD Problem Report #56436

From kim@tac.gw.fi  Sat Oct  2 19:44:02 2021
Return-Path: <kim@tac.gw.fi>
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 E7B571A921F
	for <gnats-bugs@gnats.NetBSD.org>; Sat,  2 Oct 2021 19:44:01 +0000 (UTC)
Message-Id: <20211002194351.12EBE9418D@rendez-vous.gw.fi>
Date: Sat,  2 Oct 2021 22:43:51 +0300 (EEST)
From: kim@netbsd.org (Kimmo Suominen)
Reply-To:
To: gnats-bugs@NetBSD.org
Subject: panic from scsibus scan
X-Send-Pr-Version: 3.95

>Number:         56436
>Category:       kern
>Synopsis:       panic from scsibus scan
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 02 19:45:00 +0000 2021
>Last-Modified:  Sat Oct 02 20:30:01 +0000 2021
>Originator:     kim@netbsd.org (Kimmo Suominen)
>Release:        NetBSD 9.99.89 (202109271928Z)
>Organization:
>Environment:
System: NetBSD rendez-vous.gw.fi 9.99.89 NetBSD 9.99.89 (GENERIC.202109271928Z~GW) #1: Mon Sep 27 23:08:29 EEST 2021 kim@equinoxe.x.gw.fi:/p/netbsd/work/HEAD/amd64/obj/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:

	System panics from initiating a scsibus scan:
	# scsisctl /dev/scsibus0 scan 0 3

	[ 304916.143145] panic: kernel diagnostic assertion "KERNEL_LOCKED_P()" failed: file "/p/netbsd/cvs/src/sys/kern/subr_autoconf.c", line 1053
	[ 304916.143145] cpu1: Begin traceback...
	[ 304916.143145] vpanic() at netbsd:vpanic+0x156
	[ 304916.153145] __x86_indirect_thunk_rax() at netbsd:__x86_indirect_thunk_rax
	[ 304916.153145] config_match() at netbsd:config_match+0x85
	[ 304916.153145] mapply() at netbsd:mapply+0x26
	[ 304916.153145] config_search_internal() at netbsd:config_search_internal+0x16e
	[ 304916.153145] config_search() at netbsd:config_search+0x7d
	[ 304916.153145] scsi_probe_bus() at netbsd:scsi_probe_bus+0x4be
	[ 304916.153145] VOP_IOCTL() at netbsd:VOP_IOCTL+0x47
	[ 304916.153145] vn_ioctl() at netbsd:vn_ioctl+0xad
	[ 304916.153145] sys_ioctl() at netbsd:sys_ioctl+0x56d
	[ 304916.153145] syscall() at netbsd:syscall+0x196
	[ 304916.163146] --- syscall (number 54) ---
	[ 304916.163146] netbsd:syscall+0x196:
	[ 304916.163146] cpu1: End traceback...
	[ 304916.163146] dumping to dev 168,2 (offset=8, size=4192952):
	[ 304916.163146] dump failed: insufficient space (3407872 < 4895219)
	[ 304916.933141] rebooting...

>How-To-Repeat:

	I had added a new SCSI disk to the virtual machine and wanted
	the kernel to find it, so I ran

	# scsisctl /dev/scsibus0 scan 0 3

>Fix:

>Audit-Trail:
From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/56436: panic from scsibus scan
Date: Sat, 2 Oct 2021 20:24:50 -0000 (UTC)

 kim@netbsd.org (Kimmo Suominen) writes:

 >	System panics from initiating a scsibus scan:
 >	# scsisctl /dev/scsibus0 scan 0 3

 >	[ 304916.143145] panic: kernel diagnostic assertion "KERNEL_LOCKED_P()" failed: file "/p/netbsd/cvs/src/sys/kern/subr_autoconf.c", line 1053
 >	[ 304916.143145] cpu1: Begin traceback...
 >	[ 304916.143145] vpanic() at netbsd:vpanic+0x156
 >	[ 304916.153145] __x86_indirect_thunk_rax() at netbsd:__x86_indirect_thunk_rax
 >	[ 304916.153145] config_match() at netbsd:config_match+0x85
 >	[ 304916.153145] mapply() at netbsd:mapply+0x26
 >	[ 304916.153145] config_search_internal() at netbsd:config_search_internal+0x16e
 >	[ 304916.153145] config_search() at netbsd:config_search+0x7d
 >	[ 304916.153145] scsi_probe_bus() at netbsd:scsi_probe_bus+0x4be


 The autoconf routines now largerly enforce that the kernel lock is held.

 Index: sys/dev/scsipi/scsiconf.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/scsipi/scsiconf.c,v
 retrieving revision 1.292
 diff -p -u -r1.292 scsiconf.c
 --- sys/dev/scsipi/scsiconf.c	7 Aug 2021 16:19:16 -0000	1.292
 +++ sys/dev/scsipi/scsiconf.c	2 Oct 2021 20:19:33 -0000
 @@ -1012,6 +1012,7 @@ scsi_probe_device(struct scsibus_softc *
  	locs[SCSIBUSCF_TARGET] = target;
  	locs[SCSIBUSCF_LUN] = lun;

 +	KERNEL_LOCK(1, curlwp);
  	if ((cf = config_search(sc->sc_dev, &sa,
  				CFARGS(.submatch = config_stdsubmatch,
  				       .locators = locs))) != NULL) {
 @@ -1034,7 +1035,9 @@ scsi_probe_device(struct scsibus_softc *
  		 */
  		config_attach(sc->sc_dev, cf, &sa, scsibusprint,
  		    CFARGS(.locators = locs));
 +		KERNEL_UNLOCK_ONE(curlwp);
  	} else {
 +		KERNEL_UNLOCK_ONE(curlwp);
  		scsibusprint(&sa, device_xname(sc->sc_dev));
  		aprint_normal(" not configured\n");
  		goto bad;

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.