From owner-freebsd-current@FreeBSD.ORG Mon Apr 24 12:41:12 2006 Return-Path: X-Original-To: freebsd-current@freebsd.org 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 A705516A403; Mon, 24 Apr 2006 12:41:12 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id D84A643D62; Mon, 24 Apr 2006 12:41:10 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from zion.baldwin.cx (zion.baldwin.cx [192.168.0.7]) (authenticated bits=0) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k3OCf5R1052454; Mon, 24 Apr 2006 08:41:07 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-current@freebsd.org Date: Mon, 24 Apr 2006 08:32:57 -0400 User-Agent: KMail/1.8.3 References: <200604050354.19659.mistry.7@osu.edu> <200604221459.43050.mistry.7@osu.edu> <200604221622.14785.mistry.7@osu.edu> In-Reply-To: <200604221622.14785.mistry.7@osu.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200604240832.58929.jhb@freebsd.org> X-Virus-Scanned: ClamAV 0.87.1/1423/Mon Apr 24 04:24:11 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-3.0 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00, BIZ_TLD autolearn=ham version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx Cc: Ian Dowse Subject: Re: [PATCH] ugen detach race X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 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, 24 Apr 2006 12:41:12 -0000 On Saturday 22 April 2006 04:22 pm, Anish Mistry wrote: > On Saturday 22 April 2006 14:59, Anish Mistry wrote: > > On Wednesday 05 April 2006 04:44, Anish Mistry wrote: > > > On Wednesday 05 April 2006 03:53, Anish Mistry wrote: > > > > While working on getting hplip ported I ran across a race > > > > condition in the ugen code that causes a crash. The following > > > > patch fixes a problem where read, write, and ioctl can be > > > > called during a detach since sc_dying isn't checked before > > > > bumping the reference count. This puts the sc_dying check > > > > before the *_do_* functions are called. This includes the patch > > > > from usb/81308 to prevent polling on the control endpoint. As > > > > well as a few NULL pointer checks from NetBSD. This patch is > > > > applicable to RELENG_6. > > > > > > And CURRENT. > > > > > > > http://am-productions.biz/docs/ugen-detach-race.patch > > > > > > > > This doesn't fix the case where an application has a read/write > > > > pending and then detach is called. In this case destroy_devl > > > > will just keep looping until the read/write completes. > > > > I've updated the patch. It now includes the fix for the panic on > > detach when a process has a device open when a detach occurs. ugen > > now no longer waits for the process to close the connection and > > just cuts it off. > > Applies to RELENG_6 and CURRENT. > > > > http://am-productions.biz/docs/ugen-detach-race.patch > > > > The patch should fix usb/93949 too. > > This seems to fix all the panics I'm seeing with the ugen device. > > It would be nice if this could make it into 6.1. > > I added another panic fix. An error was introduced in rev 1.94 on > ugen.c in the USB_SET_CONFIG ioctl case that calls > ugen_make_devnodes. This causes a panic since this logic was moved > to ugen_set_config a while ago. Removing the ugen_make_devnodes() > call from ugen_do_ioctl fixes the problem. This bug made it trivial > to cause a panic when there was access to any ugen device. > > http://am-productions.biz/docs/ugen-detach-race.patch Might want to send it to freebsd-usb@ to get more usb-aware folks to review= =20 it. =2D-=20 John Baldwin =A0<>< =A0http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" =A0=3D =A0http://www.FreeBSD.org