From owner-svn-src-all@FreeBSD.ORG Mon Jan 16 20:18:10 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A7581106568C; Mon, 16 Jan 2012 20:18:10 +0000 (UTC) (envelope-from das@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 96B3E8FC12; Mon, 16 Jan 2012 20:18:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q0GKIAMW050163; Mon, 16 Jan 2012 20:18:10 GMT (envelope-from das@svn.freebsd.org) Received: (from das@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q0GKIADK050161; Mon, 16 Jan 2012 20:18:10 GMT (envelope-from das@svn.freebsd.org) Message-Id: <201201162018.q0GKIADK050161@svn.freebsd.org> From: David Schultz Date: Mon, 16 Jan 2012 20:18:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r230230 - head/sys/dev/random X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Mon, 16 Jan 2012 20:18:10 -0000 Author: das Date: Mon Jan 16 20:18:10 2012 New Revision: 230230 URL: http://svn.freebsd.org/changeset/base/230230 Log: Generate a warning if the kernel's arc4random() is seeded with bogus entropy. Modified: head/sys/dev/random/harvest.c Modified: head/sys/dev/random/harvest.c ============================================================================== --- head/sys/dev/random/harvest.c Mon Jan 16 20:17:51 2012 (r230229) +++ head/sys/dev/random/harvest.c Mon Jan 16 20:18:10 2012 (r230230) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -48,6 +49,7 @@ static int read_random_phony(void *, int /* Structure holding the desired entropy sources */ struct harvest_select harvest = { 1, 1, 1, 0 }; +static int warned = 0; /* hold the address of the routine which is actually called if * the randomdev is loaded @@ -71,6 +73,7 @@ random_yarrow_deinit_harvester(void) { reap_func = NULL; read_func = read_random_phony; + warned = 0; } /* Entropy harvesting routine. This is supposed to be fast; do @@ -108,6 +111,11 @@ read_random_phony(void *buf, int count) u_long randval; int size, i; + if (!warned) { + log(LOG_WARNING, "random device not loaded; using insecure entropy\n"); + warned = 1; + } + /* srandom() is called in kern/init_main.c:proc0_post() */ /* Fill buf[] with random(9) output */