From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 7 23:33:24 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2FB5C1065678 for ; Wed, 7 Apr 2010 23:33:24 +0000 (UTC) (envelope-from aurelien@aurel32.net) Received: from hall.aurel32.net (unknown [IPv6:2a01:e0b:1:82:21c:c0ff:fe56:7beb]) by mx1.freebsd.org (Postfix) with ESMTP id BB5C28FC1C for ; Wed, 7 Apr 2010 23:33:23 +0000 (UTC) Received: from aurel32 by hall.aurel32.net with local (Exim 4.69) (envelope-from ) id 1NzekM-0000md-77; Thu, 08 Apr 2010 01:33:22 +0200 Date: Thu, 8 Apr 2010 01:33:22 +0200 From: Aurelien Jarno To: Kostik Belousov Message-ID: <20100407233322.GA31481@hall.aurel32.net> References: <20100406140308.GY2415@deviant.kiev.zoral.com.ua> <20100406140852.GZ2415@deviant.kiev.zoral.com.ua> <20100406144402.GB2415@deviant.kiev.zoral.com.ua> <20100406210321.GE2415@deviant.kiev.zoral.com.ua> <20100407095928.GG2415@deviant.kiev.zoral.com.ua> <20100407215256.GA2739@hall.aurel32.net> <20100407215841.GL2415@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20100407215841.GL2415@deviant.kiev.zoral.com.ua> X-Mailer: Mutt 1.5.18 (2008-05-17) User-Agent: Mutt/1.5.18 (2008-05-17) Sender: Aurelien Jarno X-Mailman-Approved-At: Thu, 08 Apr 2010 05:24:10 +0000 Cc: freebsd-hackers@freebsd.org, Petr Salinger Subject: Re: leak of the vnodes X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2010 23:33:24 -0000 On Thu, Apr 08, 2010 at 12:58:41AM +0300, Kostik Belousov wrote: > On Wed, Apr 07, 2010 at 11:52:56PM +0200, Aurelien Jarno wrote: > > On Wed, Apr 07, 2010 at 11:05:28PM +0200, Petr Salinger wrote: > > >>> What have to be logged ? > > >> Please look at ddb command "show files", implemented in kern/kern_descrip.c, > > >> lines 3284-3305 on HEAD. Instead of doing full dump, you can manually > > >> inspect the output. Or, you can write some code that would search the > > >> suspicious vnodes among the vnodes referenced from the processes > > >> opened files. Vnode is probably leaked if use count is > 0 but no > > >> process has vnode referenced by struct file. > > > > > > See attached file. > > > > > >>>> I think there should be something else going on. > > > > > > Bellow is leaking recipe tested under GNU/kFreeBSD. > > > I would expect it leaks vnodes also under plain FreeBSD. > > > > > > > I confirm it is reproducible on plain FreeBSD. Looks like a security > > issue, as a normal user can create a local DoS in a few dozen of > > seconds. > > I already posted the following patch in private. Thanks, I confirm it fixes the problem, at least the testcase posted by Petr. > diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c > index 5cfbc71..e9dac77 100644 > --- a/sys/kern/tty_pts.c > +++ b/sys/kern/tty_pts.c > @@ -575,6 +575,9 @@ ptsdev_close(struct file *fp, struct thread *td) > tty_lock(tp); > tty_rel_gone(tp); > > + if (fp->f_vnode != NULL) > + return (vnops.fo_close(fp, td)); > + > return (0); > } > -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net