From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 7 21:58:56 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 A2907106566C for ; Wed, 7 Apr 2010 21:58:55 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 3CBD68FC18 for ; Wed, 7 Apr 2010 21:58:54 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o37Lwfc2055187 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 8 Apr 2010 00:58:41 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o37Lwfko016846; Thu, 8 Apr 2010 00:58:41 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o37Lwf1T016845; Thu, 8 Apr 2010 00:58:41 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 8 Apr 2010 00:58:41 +0300 From: Kostik Belousov To: Aurelien Jarno Message-ID: <20100407215841.GL2415@deviant.kiev.zoral.com.ua> 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> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="KMh3oH5xaVDeKy7N" Content-Disposition: inline In-Reply-To: <20100407215256.GA2739@hall.aurel32.net> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua 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 21:58:56 -0000 --KMh3oH5xaVDeKy7N Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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_desc= rip.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. > > >=20 > 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. 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); =20 + if (fp->f_vnode !=3D NULL) + return (vnops.fo_close(fp, td)); + return (0); } --KMh3oH5xaVDeKy7N Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAku9ABAACgkQC3+MBN1Mb4gcZQCgvw+nVq4hqszvNwvkK2t7Si89 kg4AoO6hvXVO1/dc4ZpIREzXodTtFznW =sMGS -----END PGP SIGNATURE----- --KMh3oH5xaVDeKy7N--