From owner-freebsd-security@FreeBSD.ORG Tue Jun 20 02:54:00 2006 Return-Path: X-Original-To: freebsd-security@freebsd.org Delivered-To: freebsd-security@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5CC4716A479 for ; Tue, 20 Jun 2006 02:54:00 +0000 (UTC) (envelope-from nick@nickwithers.com) Received: from mail.nickwithers.com (mail.manrags.com [203.219.206.74]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9F79C43D46 for ; Tue, 20 Jun 2006 02:53:59 +0000 (GMT) (envelope-from nick@nickwithers.com) Received: from localhost (shmick.shmon.net [10.0.0.252]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.nickwithers.com (Postfix) with ESMTP id C95EA3A37A; Tue, 20 Jun 2006 12:53:50 +1000 (EST) Date: Tue, 20 Jun 2006 12:53:50 +1000 From: Nick Withers To: Dan Lukes Message-Id: <20060620125350.10d0c9ef.nick@nickwithers.com> In-Reply-To: <44967861.6070509@obluda.cz> References: <20060618203903.31161.qmail@web30306.mail.mud.yahoo.com> <44967861.6070509@obluda.cz> Organization: nickwithers.com X-Mailer: Sylpheed version 2.2.6 (GTK+ 2.8.19; i386-portbld-freebsd6.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-nickwithers-MailScanner: Found to be clean X-nickwithers-MailScanner-From: nick@nickwithers.com Cc: freebsd-security@freebsd.org Subject: Re: memory pages nulling when releasing X-BeenThere: freebsd-security@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Security issues \[members-only posting\]" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jun 2006 02:54:00 -0000 On Mon, 19 Jun 2006 12:11:45 +0200 Dan Lukes wrote: (snip) > To Nick: OS doesn't zero on free. FreeBSD does*, if the "J" flag is set in _malloc_options / MALLOC_OPTIONS, as per my original message (or at least, I believe this is the case, going by malloc(3)'s man page - please correct me if I'm wrong). * Alright, it doesn't zero, as such, but will (again, unless I've misunderstood the malloc(3) man page) initialise each byte to 0xd0 > For better security of your sensitive data you need zero the memory by > self. For inspiration I recommend to see the CRYPT_malloc/CRYPT_free > implementation in OpenSSL. Don't forget the edge situations also (when > your program can prematurely exits, you need the clean the key memory > on "atexit" or so). Good point, I hadn't thought of that! > You may need to avoid swapping of memory with sensitive data also - see > man mlock. > > But security knows no simple measures. You need think carefully about > your specific situation then decide what measures are appropriate. More > security measures may not cause more real security - it can have > opposite effect also. > > Dan > > > -- > Dan Lukes SISAL MFF UK > AKA: dan@obluda.cz, dan@freebsd.cz,dan@kolej.mff.cuni.cz -- Nick Withers email: nick@nickwithers.com Web: http://www.nickwithers.com Mobile: +61 414 397 446