From owner-freebsd-current@FreeBSD.ORG Sat Feb 9 23:34:15 2013 Return-Path: Delivered-To: current@FreeBSD.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9D7049A3; Sat, 9 Feb 2013 23:34:15 +0000 (UTC) (envelope-from pawel@dawidek.net) Received: from mail.dawidek.net (garage.dawidek.net [91.121.88.72]) by mx1.freebsd.org (Postfix) with ESMTP id 5BAB8E0A; Sat, 9 Feb 2013 23:34:15 +0000 (UTC) Received: from localhost (89-73-195-149.dynamic.chello.pl [89.73.195.149]) by mail.dawidek.net (Postfix) with ESMTPSA id 652826E7; Sun, 10 Feb 2013 00:31:21 +0100 (CET) Date: Sun, 10 Feb 2013 00:35:00 +0100 From: Pawel Jakub Dawidek To: Andriy Gapon Subject: Re: geli(8) breaks after a couple hours of uptime Message-ID: <20130209233500.GH1375@garage.freebsd.pl> References: <20130207141833.GA15884@acme.spoerlein.net> <20130207153322.5c371beb@fabiankeil.de> <20130207180153.GX35868@acme.spoerlein.net> <20130208095709.6ae61cff@fabiankeil.de> <20130208114825.GY35868@acme.spoerlein.net> <5114F390.4010302@FreeBSD.org> <20130209140733.0b753c60@fabiankeil.de> <51166580.4080603@FreeBSD.org> <511672B5.5080300@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="KIzF6Cje4W/osXrF" Content-Disposition: inline In-Reply-To: <511672B5.5080300@FreeBSD.org> X-OS: FreeBSD 10.0-CURRENT amd64 User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Eitan Adler , Andrey Zonov , current@FreeBSD.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 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: Sat, 09 Feb 2013 23:34:15 -0000 --KIzF6Cje4W/osXrF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Feb 09, 2013 at 06:00:53PM +0200, Andriy Gapon wrote: > on 09/02/2013 17:04 Andrey Zonov said the following: > > On 2/9/13 5:07 PM, Fabian Keil wrote: > >> > >> This would at least prevent the segfault. > >> > >=20 > > I see two possibilities to get segfault: > > - no checking for result from memory allocation functions > > - too big stack > >=20 > > I have no found any broken memory allocation checking, but I found two > > big objects on the stack. One is buf[MAXPHYS] in eli_genkey_files() and > > another is passbuf[MAXPHYS] in eli_genkey_passphrase(). If we change > > these two to malloc(), then we can handle error from malloc(), print > > some useful message and prevent segfault. >=20 > I'd rather do what Kostik suggested and Fabian mentioned: instead of > mlockall(MCL_FUTURE) the code should mlock only the (explicitly designate= d) > buffers that can contain sensitive data. geli(8) almost exclusively deals with sensitive data. Even mlocking MAXPHYS would fail with current limits, but this is bad idea. With mlockall() I am sure I didn't miss anything - be it forgetting about mlocking some buffer or zeroing it before munlock. I'm also sure someone else who can modify geli(8) in the future won't miss anything too. geli(8) is relatively simple program, it doesn't allocate megabytes of memory for different pruposes and just needs few pages for sensitive data. As I said most of the memory it uses is for sensitive data. The obvious problem is allocating MAXPHYS on the stack. This has to be changed, especially that we may want to rise MAXPHYS in the future. Other than that I expect thing would be tuned properly so that geli(8) can work by default. I'm happy to use smaller buffers than MAXPHYS - keyfiles are far smaller usually than 128kB, so there shouldn't be any issue with this. --=20 Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://tupytaj.pl --KIzF6Cje4W/osXrF Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAlEW3SQACgkQForvXbEpPzS94ACgyYOtEyf28arovJda9f9lLXCr X+0An0ep1vEqv12/jn3ib532EKYNpsKy =VR+x -----END PGP SIGNATURE----- --KIzF6Cje4W/osXrF--