Date: Fri, 24 Aug 2018 14:53:47 +0000 (UTC) From: Mark Murray <markm@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r338293 - head/sys/dev/random Message-ID: <201808241453.w7OErlYl010281@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markm Date: Fri Aug 24 14:53:46 2018 New Revision: 338293 URL: https://svnweb.freebsd.org/changeset/base/338293 Log: Limit the amount of "fast" entropy. We don't need nearly as much for security, and the excess just slows things down badly. PR: 230808 Submitted by: rwmaillists@googlemail.com, but tweeked by me Reported by: Danilo Egea Gondolfo <danilo@FreeBSD.org> Reviewed by: cem,delphij Approved by: re(rgrimes) Approved by: so(delphij) MFC after: 1 Month Differential Revision: https://reviews.freebsd.org/D16873 Modified: head/sys/dev/random/random_harvestq.c Modified: head/sys/dev/random/random_harvestq.c ============================================================================== --- head/sys/dev/random/random_harvestq.c Fri Aug 24 14:53:42 2018 (r338292) +++ head/sys/dev/random/random_harvestq.c Fri Aug 24 14:53:46 2018 (r338293) @@ -57,6 +57,10 @@ __FBSDID("$FreeBSD$"); #include <machine/atomic.h> #include <machine/cpu.h> +#include <crypto/rijndael/rijndael-api-fst.h> +#include <crypto/sha2/sha256.h> + +#include <dev/random/hash.h> #include <dev/random/randomdev.h> #include <dev/random/random_harvestq.h> @@ -213,8 +217,12 @@ random_sources_feed(void) /* It's an indenting error. Yeah, Yeah. */ #endif local_read_rate = atomic_readandclear_32(&read_rate); + /* Perform at least one read per round */ + local_read_rate = MAX(local_read_rate, 1); + /* But not exceeding RANDOM_KEYSIZE_WORDS */ + local_read_rate = MIN(local_read_rate, RANDOM_KEYSIZE_WORDS); LIST_FOREACH(rrs, &source_list, rrs_entries) { - for (i = 0; i < p_random_alg_context->ra_poolcount*(local_read_rate + 1); i++) { + for (i = 0; i < p_random_alg_context->ra_poolcount*local_read_rate; i++) { n = rrs->rrs_source->rs_read(entropy, sizeof(entropy)); KASSERT((n <= sizeof(entropy)), ("%s: rs_read returned too much data (%u > %zu)", __func__, n, sizeof(entropy))); /* It would appear that in some circumstances (e.g. virtualisation),
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808241453.w7OErlYl010281>