From owner-freebsd-current@FreeBSD.ORG Wed Jun 10 18:25:52 2009 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 358A91065677 for ; Wed, 10 Jun 2009 18:25:52 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id E80548FC0A for ; Wed, 10 Jun 2009 18:25:51 +0000 (UTC) (envelope-from jilles@stack.nl) Received: by mx1.stack.nl (Postfix, from userid 65534) id 548CB359942; Wed, 10 Jun 2009 20:25:51 +0200 (CEST) X-Spam-DCC: Misty: scanner01.stack.nl 1170; Body=1 Fuz1=1 Fuz2=1 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on scanner01.stack.nl X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,NO_RELAYS autolearn=ham version=3.2.5 X-Spam-Relay-Country: _RELAYCOUNTRY_ Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 18B34359889; Wed, 10 Jun 2009 20:25:49 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id BBE01228CB; Wed, 10 Jun 2009 20:25:23 +0200 (CEST) Date: Wed, 10 Jun 2009 20:25:23 +0200 From: Jilles Tjoelker To: Jille Timmermans Message-ID: <20090610182523.GB50651@stack.nl> References: <4A2D62B6.9080207@quis.cx> <20090609211621.GA24874@stack.nl> <4A2ED513.101@quis.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4A2ED513.101@quis.cx> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: FreeBSD Current Subject: Re: panic: oof, we didn't get our fd while playing with devfs(8) and jails 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: Wed, 10 Jun 2009 18:25:52 -0000 On Tue, Jun 09, 2009 at 11:33:07PM +0200, Jille Timmermans wrote: > I'm sorry, I forgot to tell that error = 0. (and INVARIANTS is enabled) > (kgdb) frame 3 > #3 0xc0609399 in fdcheckstd (td=0xc41bfd80) > at /usr/src/sys/kern/kern_descrip.c:1946 > 1946 KASSERT(devnull == i, ("oof, we didn't > get our fd")); > (kgdb) print error > $1 = 0 > might this have anything to do with the lockless file descriptor lookup > ? (Cc'ing jeff@) > I have reproduced the panic a second time; but haven't figured out why > it didn't panic my third time. > I talked about this with ed@ on IRC; but after that my best guess was > that kern_open() was mistaking. Sometimes gdb just shows 0 instead of the correct value of a variable, so do not trust too much that kern_open() did not report an error. In the fstat output I saw that the problematic process had fd 0 open as a pipe and fd 1 and 2 closed, and its parent was a cron(8) process. Now, the cron_popen() function in usr.sbin/cron/cron/popen.c that cron uses to mail things out opens _PATH_DEVNULL on fd 1 and 2 without checking if it succeeds. So it is likely there was something wrong with /dev/null in that jail. > We also wondered why the kernel doesn't always have a devnull file > descriptor ready, I guess it is usefull in more cases. It is not used _that_ much, and I think the current approach has less code complexity. Sharing the open file (like dup and sending file descriptors over unix sockets) seems unwise because some state could be shared across entirely unknowing processes (for example, fcntl with F_SETFL will affect /dev/null open files to some degree even though it returns an error code). Then, because /dev/null is very much like any other device, the file descriptor would likely have to be hand-crafted to a great extent. -- Jilles Tjoelker