From 65b38a2193fdc52a055fe091c9dcc1e9ef04d3a9 Mon Sep 17 00:00:00 2001 From: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com> Date: Sun, 22 Nov 2026 01:10:50 +0000 Subject: [PATCH] soc: apple: sep: credit the enclave RNG at 900, as a policy The SEP hwrng registers with quality 1024. That tells the hwrng core that every bit read is fully random, so the core credits all of it to the kernel's entropy pool. This change is a policy choice, not a fix for a known weakness. Nothing shows that the enclave's output is weaker than 1024 claims. Nothing public shows that it is as strong either: there is no analysis of its noise source, or of how its firmware conditions the output before it reaches the mailbox. The policy proposed here is that a source with no such analysis does not get full credit by default. 900 is the value most SoC TRNG drivers declare under that policy, without a measurement of their own (omap-rng, stm32-rng, mtk-rng and others). What changes: the pool is credited 900/1024 of the bits the SEP gives. The device still feeds the pool at the same rate, and is still chosen as the current hwrng when it is the only one. An administrator who trusts the source can set rng_quality back to 1024 through sysfs. If the maintainers prefer to trust the SEP by default, this patch can be dropped; nothing else depends on it. Checked by reading drivers/char/hw_random/core.c: quality is clamped to min(default_quality, 1024, quality) at registration and scales the credit in hwrng_fillfn(). The kernel Rust code was not compiled here. Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com> --- drivers/soc/apple/hwrng.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/soc/apple/hwrng.rs b/drivers/soc/apple/hwrng.rs index 92f3ac7043a78..e5b97a6318929 100644 --- a/drivers/soc/apple/hwrng.rs +++ b/drivers/soc/apple/hwrng.rs @@ -21,7 +21,12 @@ extern "C" { fn sep_hwrng_unregister(mem: *mut c_void); } -pub(crate) const QUALITY: c_ushort = 1024; +/// Bits of entropy credited per 1024 bits read. This is a policy, not a +/// measurement: a source with no public analysis of its noise and of how its +/// firmware conditions it does not get full credit by default. 900 is what +/// most SoC TRNG drivers declare under the same policy (omap, stm32, mtk). +/// An administrator can change it through hw_random's rng_quality. +pub(crate) const QUALITY: c_ushort = 900; pub(crate) const NAME: &CStr = c"apple-sep";