NetBSD Problem Report #44283

From www@NetBSD.org  Mon Dec 27 14:06:05 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 050B663BA6E
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 27 Dec 2010 14:06:05 +0000 (UTC)
Message-Id: <20101227140604.A5E8863B9D1@www.NetBSD.org>
Date: Mon, 27 Dec 2010 14:06:04 +0000 (UTC)
From: rherdware@yahoo.com
Reply-To: rherdware@yahoo.com
To: gnats-bugs@NetBSD.org
Subject: ses(4) panics the kernel when detached
X-Send-Pr-Version: www-1.0

>Number:         44283
>Category:       kern
>Synopsis:       ses(4) panics the kernel when detached
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 27 14:10:00 +0000 2010
>Closed-Date:    Sun Apr 07 18:51:01 +0000 2013
>Last-Modified:  Mon Apr 29 03:20:15 +0000 2013
>Originator:     Björn Johannesson
>Release:        5.99.41
>Organization:
>Environment:
NetBSD fafner 5.99.41 NetBSD 5.99.41 (GENERIC) #0: Thu Dec 23 18:11:13 CET 2010  bjorn@fafner:/usr/obj/sys/arch/i386/compile/GENERIC i386
>Description:
When a ses(4) device is detached the kernel panics.

I recently bought a new external USB-drive:
sd6 at scsibus3 target 0 lun 0: <WD, My Book 1130, 1012> disk fixed
sd6: fabricating a geometry
sd6: 2794 GB, 357694 cyl, 64 head, 32 sec, 4096 bytes/sect x 732558336 sectors
it also presents it self as a ses(4)device:
ses1 at scsibus3 target 0 lun 1: <WD, SES Device, 1012> enclosure services fixed
ses1: SCSI-3 SES Device

When you unplug the drive the kernel panics:
NB: The disk was attached to another port when this crash occured so it's called sd5/ses0 here.
sd5: detached
panic: config_detach: forced detach of ses0 failed (45)
fatal breakpoint trap in supervisor mode
trap type 1 code 0 eip c022baf4 cs 8 eflags 246 cr2 bb940000 ilevel 0

bactrace:
#0  0xc04bb5f1 in cpu_reboot ()
#1  0xc061cbe2 in panic ()
#2  0xc060d72b in config_detach ()
#3  0xc05d924f in scsipi_target_detach ()
#4  0xc05d7734 in scsibusdetach ()
#5  0xc060d5f2 in config_detach ()
#6  0xc06a4491 in umass_detach ()
#7  0xc060d5f2 in config_detach ()
#8  0xc06ad8ba in usb_disconnect_port ()
#9  0xc069215b in uhub_explore ()
#10 0xc06ab9e5 in usb_discover ()
#11 0xc06abd57 in usb_event_thread ()
#12 0xc0100321 in lwp_trampoline ()

>How-To-Repeat:
Hot-unplug a usb disk with a ses(4)-function.
>Fix:
A workaround is to disable ses(4) with ukc or compile a kernel without ses(4).

>Release-Note:

>Audit-Trail:
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/44283: ses(4) panics the kernel when detached
Date: Mon, 13 Jun 2011 00:03:29 +0000

 On Mon, Dec 27, 2010 at 02:10:00PM +0000, rherdware@yahoo.com wrote:
  > When a ses(4) device is detached the kernel panics.

 Also see 44566, which I closed as a duplicate. This affects -5, so any
 suitable fix should be pulled up.

 -- 
 David A. Holland
 dholland@netbsd.org

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/44283: ses(4) panics the kernel when detached
Date: Mon, 13 Jun 2011 00:13:19 +0000

 On Mon, Jun 13, 2011 at 12:05:04AM +0000, David Holland wrote:
  >   > When a ses(4) device is detached the kernel panics.
  >  
  >  Also see 44566, which I closed as a duplicate. This affects -5, so any
  >  suitable fix should be pulled up.

 ...and 44676.

 -- 
 David A. Holland
 dholland@netbsd.org

From: diro@nixsyspaus.org
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/44283
Date: Thu, 20 Dec 2012 11:23:19 -0500

 This is still an issue in NetBSD/amd64 6.0. It's quite reproducible in my
 environment.

From: diro@nixsyspaus.org
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/44283
Date: Tue, 5 Mar 2013 12:21:10 -0500

 I haven't seen any progress on this and since 6.1 is RC1, can we disable ses*
 in the GENERIC kernel until it's fixed? It is a bit ironic that a "stable"
 release would included something that causes the system to become unusable
 after performing such a trivial operation as unplugging a hard drive.

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: rherdware@yahoo.com
Subject: Re: kern/44283
Date: Thu, 7 Mar 2013 12:53:44 +0100

 --GvXjxJ+pjyke8COw
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 Could you try the attached (untested) patch?

 Martin

 --GvXjxJ+pjyke8COw
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=patch

 Index: ses.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/scsipi/ses.c,v
 retrieving revision 1.44
 diff -u -p -r1.44 ses.c
 --- ses.c	27 Oct 2012 17:18:38 -0000	1.44
 +++ ses.c	7 Mar 2013 11:52:37 -0000
 @@ -168,10 +168,11 @@ struct ses_softc {

  static int ses_match(device_t, cfdata_t, void *);
  static void ses_attach(device_t, device_t, void *);
 +static int ses_detach(device_t, int);
  static enctyp ses_device_type(struct scsipibus_attach_args *);

  CFATTACH_DECL_NEW(ses, sizeof (struct ses_softc),
 -    ses_match, ses_attach, NULL, NULL);
 +    ses_match, ses_attach, ses_detach, NULL);

  extern struct cfdriver ses_cd;

 @@ -276,7 +277,6 @@ ses_attach(device_t parent, device_t sel
  	printf("\n%s: %s\n", device_xname(softc->sc_dev), tname);
  }

 -
  static enctyp
  ses_device_type(struct scsipibus_attach_args *sa)
  {
 @@ -811,6 +811,29 @@ ses_softc_init(ses_softc_t *ssc, int doi
  }

  static int
 +ses_detach(device_t self, int flags)
 +{
 +	struct ses_softc *ssc = device_private(self);
 +	struct sscfg *cc = ssc->ses_private;
 +
 +	if (ssc->ses_objmap) {
 +		SES_FREE(ssc->ses_objmap, (nobj * sizeof (encobj)));
 +	}
 +	if (cc != NULL) {
 +		if (cc->ses_typidx) {
 +			SES_FREE(cc->ses_typidx,
 +			    (nobj * sizeof (struct typidx)));
 +		}
 +		if (cc->ses_eltmap) {
 +			SES_FREE(cc->ses_eltmap, ntype);
 +		}
 +		SES_FREE(cc, sizeof (struct sscfg));
 +	}
 +
 +	return 0;
 +}
 +
 +static int
  ses_init_enc(ses_softc_t *ssc)
  {
  	return (0);

 --GvXjxJ+pjyke8COw--

State-Changed-From-To: open->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Sun, 07 Apr 2013 18:51:01 +0000
State-Changed-Why:
Fixed in current, thanks for the bug report.


From: "Thomas Klausner" <wiz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/44283 CVS commit: src/sys/dev/scsipi
Date: Sun, 7 Apr 2013 18:50:34 +0000

 Module Name:	src
 Committed By:	wiz
 Date:		Sun Apr  7 18:50:34 UTC 2013

 Modified Files:
 	src/sys/dev/scsipi: ses.c

 Log Message:
 Add detach support. From martin@.
 "Works for me."

 Addresses PR 44283.


 To generate a diff of this commit:
 cvs rdiff -u -r1.44 -r1.45 src/sys/dev/scsipi/ses.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/44283 CVS commit: [netbsd-6-0] src/sys/dev/scsipi
Date: Mon, 29 Apr 2013 03:15:47 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Mon Apr 29 03:15:47 UTC 2013

 Modified Files:
 	src/sys/dev/scsipi [netbsd-6-0]: ses.c

 Log Message:
 Pull up following revision(s) (requested by jakllsch in ticket #878):
 	sys/dev/scsipi/ses.c: revision 1.45
 Add detach support. From martin@.
 "Works for me."
 Addresses PR 44283.


 To generate a diff of this commit:
 cvs rdiff -u -r1.43 -r1.43.14.1 src/sys/dev/scsipi/ses.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/44283 CVS commit: [netbsd-6] src/sys/dev/scsipi
Date: Mon, 29 Apr 2013 03:17:01 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Mon Apr 29 03:17:01 UTC 2013

 Modified Files:
 	src/sys/dev/scsipi [netbsd-6]: ses.c

 Log Message:
 Pull up following revision(s) (requested by jakllsch in ticket #878):
 	sys/dev/scsipi/ses.c: revision 1.45
 Add detach support. From martin@.
 "Works for me."
 Addresses PR 44283.


 To generate a diff of this commit:
 cvs rdiff -u -r1.43 -r1.43.8.1 src/sys/dev/scsipi/ses.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.