From owner-svn-src-all@FreeBSD.ORG Wed Apr 1 01:22:31 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8846F51B; Wed, 1 Apr 2015 01:22:31 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 73D408BF; Wed, 1 Apr 2015 01:22:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t311MUBS038770; Wed, 1 Apr 2015 01:22:30 GMT (envelope-from dteske@FreeBSD.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t311MUtm038769; Wed, 1 Apr 2015 01:22:30 GMT (envelope-from dteske@FreeBSD.org) Message-Id: <201504010122.t311MUtm038769@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dteske set sender to dteske@FreeBSD.org using -f From: Devin Teske Date: Wed, 1 Apr 2015 01:22:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280935 - head/sys/boot/forth X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Apr 2015 01:22:31 -0000 Author: dteske Date: Wed Apr 1 01:22:30 2015 New Revision: 280935 URL: https://svnweb.freebsd.org/changeset/base/280935 Log: Securely overwrite (zero) user input when we finish password checks. MFC after: 3 days X-MFC-to: stable/10 Modified: head/sys/boot/forth/check-password.4th Modified: head/sys/boot/forth/check-password.4th ============================================================================== --- head/sys/boot/forth/check-password.4th Wed Apr 1 01:17:36 2015 (r280934) +++ head/sys/boot/forth/check-password.4th Wed Apr 1 01:22:30 2015 (r280935) @@ -78,6 +78,17 @@ variable readlen \ input len again ; +: cfill ( c c-addr/u -- ) + begin dup 0> while + -rot 2dup c! 1+ rot 1- + repeat 2drop drop +; + +: read-reset ( -- ) + 0 readlen ! + 0 readval readmax cfill +; + : read ( c-addr/u -- ) \ Expects string prompt as stack input 0 25 at-xy \ Move the cursor to the bottom-left @@ -127,10 +138,8 @@ variable readlen \ input len while 3000 ms ." loader: incorrect password" 10 emit repeat - 2drop ( c-addr/u ) - else - drop ( -1 ) \ getenv cruft - then + 2drop read-reset + else drop then \ Exit if a password was not set s" password" getenv -1 = if exit else drop then @@ -147,7 +156,7 @@ variable readlen \ input len begin s" Password: " read ( prompt -- ) 2dup readval readlen @ compare 0= if \ Correct password? - 2drop exit + 2drop read-reset exit then 3000 ms ." loader: incorrect password" 10 emit again