aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Spelvin <[email protected]>2020-03-30 17:38:01 +0000
committerWill Deacon <[email protected]>2020-04-28 13:55:51 +0100
commit99ee28d99607d15c6b88c4a9b9fb4a9f0ebf598c (patch)
tree7715e2cea292b716d4042c947891333a6cadbd30
parent348a625deef13d7f8537b9704d29d05cafdd8e72 (diff)
arm64: kexec_file: Avoid temp buffer for RNG seed
After using get_random_bytes(), you want to wipe the buffer afterward so the seed remains secret. In this case, we can eliminate the temporary buffer entirely. fdt_setprop_placeholder() returns a pointer to the property value buffer, allowing us to put the random data directly in there without using a temporary buffer at all. Faster and less stack all in one. Signed-off-by: George Spelvin <[email protected]> Acked-by: Will Deacon <[email protected]> Cc: Hsin-Yi Wang <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
-rw-r--r--arch/arm64/kernel/machine_kexec_file.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c
index b40c3b0def92..e5cbf91aadfe 100644
--- a/arch/arm64/kernel/machine_kexec_file.c
+++ b/arch/arm64/kernel/machine_kexec_file.c
@@ -138,12 +138,12 @@ static int setup_dtb(struct kimage *image,
/* add rng-seed */
if (rng_is_initialized()) {
- u8 rng_seed[RNG_SEED_SIZE];
- get_random_bytes(rng_seed, RNG_SEED_SIZE);
- ret = fdt_setprop(dtb, off, FDT_PROP_RNG_SEED, rng_seed,
- RNG_SEED_SIZE);
+ void *rng_seed;
+ ret = fdt_setprop_placeholder(dtb, off, FDT_PROP_RNG_SEED,
+ RNG_SEED_SIZE, &rng_seed);
if (ret)
goto out;
+ get_random_bytes(rng_seed, RNG_SEED_SIZE);
} else {
pr_notice("RNG is not initialised: omitting \"%s\" property\n",
FDT_PROP_RNG_SEED);