From owner-svn-src-all@freebsd.org Tue Apr 16 21:32:44 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 677DA157E336; Tue, 16 Apr 2019 21:32:44 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 06C4F818E9; Tue, 16 Apr 2019 21:32:44 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro-3.local (unknown [IPv6:2601:648:8880:1e30:50e5:2fcc:d66f:cb37]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 660E916C37; Tue, 16 Apr 2019 21:32:43 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: svn commit: r346250 - in head: share/man/man4 share/man/man9 sys/dev/random sys/kern sys/libkern sys/sys To: Conrad Meyer , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201904151840.x3FIeaEQ009242@repo.freebsd.org> From: John Baldwin Openpgp: preference=signencrypt Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XP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F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: <457a2c63-f062-8fc6-15d4-6f5b93981930@FreeBSD.org> Date: Tue, 16 Apr 2019 14:32:42 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <201904151840.x3FIeaEQ009242@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 06C4F818E9 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.94)[-0.942,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Tue, 16 Apr 2019 21:32:44 -0000 On 4/15/19 11:40 AM, Conrad Meyer wrote: > Author: cem > Date: Mon Apr 15 18:40:36 2019 > New Revision: 346250 > URL: https://svnweb.freebsd.org/changeset/base/346250 > > Log: > random(4): Block read_random(9) on initial seeding > > read_random() is/was used, mostly without error checking, in a lot of > very sensitive places in the kernel -- including seeding the widely used > arc4random(9). > > Most uses, especially arc4random(9), should block until the device is seeded > rather than proceeding with a bogus or empty seed. I did not spy any > obvious kernel consumers where blocking would be inappropriate (in the > sense that lack of entropy would be ok -- I did not investigate locking > angle thoroughly). In many instances, arc4random_buf(9) or that family > of APIs would be more appropriate anyway; that work was done in r345865. There are definitely places arc4random is used where sleeping is not allowed. ipsec generating nonces for AES-CBC is one example I can think of off the top of my head. I think it might be useful to add an explicit WITNESS_WARN in arc4random to catch these cases so they can be found and reasoned about. > This change primarily impacts the behavior of /dev/random on embedded > systems with read-only media that do not configure "nodevice random". We > toggle the default from 'charge on blindly with no entropy' to 'block > indefinitely.' This default is safer, but may cause frustration. Embedded > system designers using FreeBSD have several options. The most obvious is to > plan to have a small writable NVRAM or NAND to persist entropy, like larger > systems. Early entropy can be fed from any loader, or by writing directly > to /dev/random during boot. Some embedded SoCs now provide a fast hardware > entropy source; this would also work for quickly seeding Fortuna. A 3rd > option would be creating an embedded-specific, more simplistic random > module, like that designed by DJB in [1] (this design still requires a small > rewritable media for forward secrecy). Finally, the least preferred option > might be "nodevice random", although I plan to remove this in a subsequent > revision. Note that I actually often run into unseeded systems when doing development using qemu for non-x86 architectures. For example, when booting mips from qemu, there is no loader, the kernel just starts, and since the endian is opposite, I frequently regenerate the filesystem using makefs. -- John Baldwin