From nobody Fri Nov 13 00:39:13 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jQdg55Zfvz6xvJk for ; Fri, 13 Nov 2026 00:39:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jQdg5503jz4f8T for ; Fri, 13 Nov 2026 00:39:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794530353; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/+m/gcWJNBq7kHbtbebN0/DQd0j4afswbwqdJi+CLsc=; b=tunNSnRhHNrshUMN3UVsiEYuGlHWRsmiv4+GIbP8KgyODhVLJkg6eECyfvMz1Kno/c+KHW WsuzSnedQoj5G1OpffMPEgzXS6V+vhV/Olw328y7KbFuPD+DsOVrDdCuvtOXP7JJlVcNF+ 5v6oB3xBCLWPbiA6QjgnPOI9A+HDh+TnjQ3s7L7Z9ggSnfcQ0C+3R65178nsbEWPZf/4Sh xHscZfYSb5JvR80M5V240OPiXe/9jXp/fzRKpu/UXcre6JEpfVndzUd5pJFBPQLGxewSKU L2DFWJTMMuCdq09diB4x3D92G65NcnXEv+szx6C7Ia5XgXW4GpE/p3JxYAo05w== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794530353; b=xenn0BHrLqJLawiZJYP5flfHpvMF67acMsG8uJSHQKFywKnT50Gl8Dtj3ulAl1N1i5PJSD Pc1KECKr0JkN9p/fOV/646b0ObJARkzHCJWgledUBzSZFS3DRmRR/gxgWLwmigKNs10Zdz Hkpx5TeTyDVHz8zFLCR5/g6Sk7plC5xTeCiGtIXyjcLtkTsxSRgTqxoag+f64iDQbQpIGs N9vGhcfE2HtlNhV6Ic1gxI/BwEHsD127UoBNyuVp4AGSerTawoDV1abvETv46G3rFxS9KY FQQoOG1LPOaR1VKngLJmIRrpUSr9uS946xfr3l0aTksl5r11cjTylUyrRQweyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794530353; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/+m/gcWJNBq7kHbtbebN0/DQd0j4afswbwqdJi+CLsc=; b=d+wPKyGWxDD2DjFF7dkQBTxIcwjTZWYb5CA9iAvP+/uWdMpmiPZ+ScbOXVbRJ7Vdt8vdRT DdrPiDsK5pEbaCz4xkSRhmHUErLrwGXQgvS1fYmy2CW15TQE6aoJdkXKjDff65cOacjBq4 lck82MUqttYXmo4hGkVG1lSPgZzx7eg69JTmUU+m3wddp3kBKoNkFTrgtn5AgSyPpQNsjX jQqT/3oPmd4kyoDcfEhk7kE2DHOsbX6QlFnaM2JRxD5cZz6Mt2akv5ecdwjzRMrmYUPecq tF+GXDfTet2vZjcqyd4zfg1rQmVaoRDqopDRSW4W4ooFRt/0b7NAXaDRHq2bpA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jQdg54fgYz1PsZ for ; Fri, 13 Nov 2026 00:39:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1529a by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 13 Nov 2026 00:39:13 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 9c154d202881 - stable/15 - tpm20: Preserve all harvested random bytes List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 9c154d2028810af786d29c81a7cec6c60deac18c Auto-Submitted: auto-generated Date: Fri, 13 Nov 2026 00:39:13 +0000 Message-Id: <6af65c31.1529a.6536a5ed@gitrepo.freebsd.org> The branch stable/15 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=9c154d2028810af786d29c81a7cec6c60deac18c commit 9c154d2028810af786d29c81a7cec6c60deac18c Author: Kevin Bowling AuthorDate: 2026-08-28 00:32:33 +0000 Commit: Kevin Bowling CommitDate: 2026-11-13 00:39:05 +0000 tpm20: Preserve all harvested random bytes The TPM requests 16 random bytes every ten seconds, but a random harvest event retains at most eight bytes. random_harvest_queue() reduces a larger input to one 32-bit Jenkins hash, so each successful TPM request contributed only four bytes to the entropy accumulator. Split the response into harvest event sized chunks. This preserves all 16 random bytes without increasing the TPM command rate or changing its high quality source classification. Sponsored by: BBOX.io Differential Revision: https://reviews.freebsd.org/D59246 (cherry picked from commit 914892d374e924cae2a0a1d7a669f246a845ad35) --- sys/dev/tpm/tpm20.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/sys/dev/tpm/tpm20.c b/sys/dev/tpm/tpm20.c index 6c96f1ce848d..b5d40eeac7d7 100644 --- a/sys/dev/tpm/tpm20.c +++ b/sys/dev/tpm/tpm20.c @@ -32,6 +32,10 @@ #include "tpm20.h" +#if defined TPM_HARVEST || defined RANDOM_ENABLE_TPM +#include +#endif + #define TPM_HARVEST_SIZE 16 #define TPM2_ST_NO_SESSIONS 0x8001 @@ -57,6 +61,7 @@ MALLOC_DEFINE(M_TPM20, "tpm_buffer", "buffer for tpm 2.0 driver"); #if defined TPM_HARVEST || defined RANDOM_ENABLE_TPM static void tpm20_harvest(void *arg, int unused); +static void tpm20_harvest_enqueue(const uint8_t *, size_t); #endif static int tpm20_command(device_t, uint32_t, uint16_t, uint32_t, const char *); @@ -388,6 +393,23 @@ tpm20_shutdown(device_t dev) } #if defined TPM_HARVEST || defined RANDOM_ENABLE_TPM +static void +tpm20_harvest_enqueue(const uint8_t *entropy, size_t entropy_size) +{ + size_t chunk_size; + + /* Preserve all RNG bytes rather than squashing an oversized event. */ + chunk_size = sizeof(((struct harvest_event *)0)->he_entropy); + while (entropy_size != 0) { + size_t size; + + size = MIN(entropy_size, chunk_size); + random_harvest_queue(entropy, (u_int)size, RANDOM_PURE_TPM); + entropy += size; + entropy_size -= size; + } +} + /* * Get TPM_HARVEST_SIZE random bytes and add them * into system entropy pool. @@ -434,7 +456,7 @@ tpm20_harvest(void *arg, int unused) sx_xunlock(&sc->dev_lock); if (entropy_size > 0) - random_harvest_queue(entropy, entropy_size, RANDOM_PURE_TPM); + tpm20_harvest_enqueue(entropy, entropy_size); } #endif /* TPM_HARVEST */