From owner-freebsd-current@FreeBSD.ORG Mon Jan 26 11:11:54 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5BB7C16A4CE for ; Mon, 26 Jan 2004 11:11:54 -0800 (PST) Received: from smtp.des.no (flood.des.no [217.116.83.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id B689043D53 for ; Mon, 26 Jan 2004 11:11:32 -0800 (PST) (envelope-from des@des.no) Received: by smtp.des.no (Pony Express, from userid 666) id 755135309; Mon, 26 Jan 2004 20:11:30 +0100 (CET) Received: from dwp.des.no (des.no [80.203.228.37]) by smtp.des.no (Pony Express) with ESMTP id 00EC95308 for ; Mon, 26 Jan 2004 20:11:20 +0100 (CET) Received: by dwp.des.no (Postfix, from userid 2602) id 7802833C6A; Mon, 26 Jan 2004 20:11:20 +0100 (CET) To: current@freebsd.org From: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) Date: Mon, 26 Jan 2004 20:11:20 +0100 Message-ID: User-Agent: Gnus/5.090024 (Oort Gnus v0.24) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Checker-Version: SpamAssassin 2.61 (1.212.2.1-2003-12-09-exp) on flood.des.no X-Spam-Level: ss X-Spam-Status: No, hits=2.6 required=5.0 tests=RCVD_IN_DYNABLOCK, RCVD_IN_SORBS autolearn=no version=2.61 Subject: usb panic X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jan 2004 19:11:54 -0000 Doing "kldunload ums; kldload ums" while a mouse was connected (to trigger a devd event without having to physically disconnect and reconnect the mouse) triggered the following panic: kernel: type 12 trap, code=3D0 Stopped at strncpy+0x14: movb 0(%edx),%al db> where strncpy(c66a6524,0,10,c1745504,c66a6400) at strncpy+0x14 usbd_fill_deviceinfo(c5f92900,c66a6400,1,0,c05b707e) at usbd_fill_deviceinf= o+0x121 usbioctl(c05ffe20,c1745504,c66a6400,1,c64aa690) at usbioctl+0x223 spec_ioctl(ec00ab88,ec00ac34,c04f4c0f,ec00ab88,c05f7bc0) at spec_ioctl+0xf2 spec_vnoperate(ec00ab88) at spec_vnoperate+0x13 vn_ioctl(c63f3aa0,c1745504,c66a6400,c66fb080,c64aa690) at vn_ioctl+0x17f ioctl(c64aa690,ec00ad14,3,1,282) at ioctl+0x37c syscall(2f,2f,2f,6,0) at syscall+0x22b Xint0x80_syscall() at Xint0x80_syscall+0x1d --- syscall (54, FreeBSD ELF32, ioctl), eip =3D 0x880b7a17, esp =3D 0xbfbfe= 2ac, ebp =3D 0xbfbfe458 --- as usual, dumps are broken, but the code at least looks like this: (gdb) l *(usbd_fill_deviceinfo+0x121) 0x33d5 is in usbd_fill_deviceinfo (/usr/src/sys/dev/usb/usb_subr.c:1282). 1277 if (dev->subdevs !=3D NULL) { 1278 for (i =3D 0; dev->subdevs[i] && 1279 i < USB_MAX_DEVNAMES; i++) { 1280 strncpy(di->udi_devnames[i], USBDEVPTRNAME(= dev->subdevs[i]), 1281 USB_MAX_DEVNAMELEN); 1282 di->udi_devnames[i][USB_MAX_DEVNAMELEN-1] = =3D '\0'; 1283 } 1284 } else { 1285 i =3D 0; 1286 } so dev->subdevs[i] is not NULL, but it does not have a name since USBDEVPTRNAME(dev->subdevs[i]) is NULL. Looks like better locking and invariants are required; it shouldn't be possible (IMHO) for that code to stumble across an incomplete bdev. (BTW, we should use strlcpy() here rather than strncpy()) DES --=20 Dag-Erling Sm=F8rgrav - des@des.no