Patch "random: early initialization of ChaCha constants" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    random: early initialization of ChaCha constants

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     random-early-initialization-of-chacha-constants.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From foo@baz Fri Jun 17 08:58:56 AM CEST 2022
From: Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 31 Dec 2021 09:26:08 +0100
Subject: random: early initialization of ChaCha constants

From: Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx>

commit 96562f286884e2db89c74215b199a1084b5fb7f7 upstream.

Previously, the ChaCha constants for the primary pool were only
initialized in crng_initialize_primary(), called by rand_initialize().
However, some randomness is actually extracted from the primary pool
beforehand, e.g. by kmem_cache_create(). Therefore, statically
initialize the ChaCha constants for the primary pool.

Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
Cc: <linux-crypto@xxxxxxxxxxxxxxx>
Signed-off-by: Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Jason A. Donenfeld <Jason@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/char/random.c     |    5 ++++-
 include/crypto/chacha20.h |   15 +++++++++++----
 2 files changed, 15 insertions(+), 5 deletions(-)

--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -458,6 +458,10 @@ struct crng_state {
 
 static struct crng_state primary_crng = {
 	.lock = __SPIN_LOCK_UNLOCKED(primary_crng.lock),
+	.state[0] = CHACHA_CONSTANT_EXPA,
+	.state[1] = CHACHA_CONSTANT_ND_3,
+	.state[2] = CHACHA_CONSTANT_2_BY,
+	.state[3] = CHACHA_CONSTANT_TE_K,
 };
 
 /*
@@ -825,7 +829,6 @@ static void crng_initialize_secondary(st
 
 static void __init crng_initialize_primary(struct crng_state *crng)
 {
-	chacha_init_consts(crng->state);
 	_extract_entropy(&input_pool, &crng->state[4], sizeof(__u32) * 12, 0);
 	if (crng_init_try_arch_early(crng) && trust_cpu && crng_init < 2) {
 		invalidate_batched_entropy();
--- a/include/crypto/chacha20.h
+++ b/include/crypto/chacha20.h
@@ -24,12 +24,19 @@ int crypto_chacha20_setkey(struct crypto
 			   unsigned int keysize);
 int crypto_chacha20_crypt(struct skcipher_request *req);
 
+enum chacha_constants { /* expand 32-byte k */
+	CHACHA_CONSTANT_EXPA = 0x61707865U,
+	CHACHA_CONSTANT_ND_3 = 0x3320646eU,
+	CHACHA_CONSTANT_2_BY = 0x79622d32U,
+	CHACHA_CONSTANT_TE_K = 0x6b206574U
+};
+
 static inline void chacha_init_consts(u32 *state)
 {
-	state[0]  = 0x61707865; /* "expa" */
-	state[1]  = 0x3320646e; /* "nd 3" */
-	state[2]  = 0x79622d32; /* "2-by" */
-	state[3]  = 0x6b206574; /* "te k" */
+	state[0]  = CHACHA_CONSTANT_EXPA;
+	state[1]  = CHACHA_CONSTANT_ND_3;
+	state[2]  = CHACHA_CONSTANT_2_BY;
+	state[3]  = CHACHA_CONSTANT_TE_K;
 }
 
 #endif


Patches currently in stable-queue which might be from linux@xxxxxxxxxxxxxxxxxxxx are

queue-4.19/random-do-not-take-pool-spinlock-at-boot.patch
queue-4.19/random-simplify-arithmetic-function-flow-in-account.patch
queue-4.19/random-introduce-drain_entropy-helper-to-declutter-crng_reseed.patch
queue-4.19/random-fix-locking-in-crng_fast_load.patch
queue-4.19/random-cleanup-uuid-handling.patch
queue-4.19/random-group-userspace-read-write-functions.patch
queue-4.19/random-make-credit_entropy_bits-always-safe.patch
queue-4.19/random-do-not-re-init-if-crng_reseed-completes-before-primary-init.patch
queue-4.19/random-pull-add_hwgenerator_randomness-declaration-into-random.h.patch
queue-4.19/random-unify-early-init-crng-load-accounting.patch
queue-4.19/random-remove-incomplete-last_data-logic.patch
queue-4.19/random-group-entropy-extraction-functions.patch
queue-4.19/random-add-proper-spdx-header.patch
queue-4.19/random-rewrite-header-introductory-comment.patch
queue-4.19/random-remove-ifdef-d-out-interrupt-bench.patch
queue-4.19/random-tie-batched-entropy-generation-to-base_crng-generation.patch
queue-4.19/random-use-linear-min-entropy-accumulation-crediting.patch
queue-4.19/random-remove-batched-entropy-locking.patch
queue-4.19/random-continually-use-hwgenerator-randomness.patch
queue-4.19/random-access-input_pool_data-directly-rather-than-through-pointer.patch
queue-4.19/random-inline-leaves-of-rand_initialize.patch
queue-4.19/random-cleanup-poolinfo-abstraction.patch
queue-4.19/random-handle-latent-entropy-and-command-line-from-random_init.patch
queue-4.19/random-credit-architectural-init-the-exact-amount.patch
queue-4.19/random-replace-custom-notifier-chain-with-standard-one.patch
queue-4.19/random-avoid-initializing-twice-in-credit-race.patch
queue-4.19/random-zero-buffer-after-reading-entropy-from-userspace.patch
queue-4.19/random-remove-whitespace-and-reorder-includes.patch
queue-4.19/random-clear-fast-pool-crng-and-batches-in-cpuhp-bring-up.patch
queue-4.19/random-do-crng-pre-init-loading-in-worker-rather-than-irq.patch
queue-4.19/random-early-initialization-of-chacha-constants.patch
queue-4.19/random-simplify-entropy-debiting.patch
queue-4.19/random-skip-fast_init-if-hwrng-provides-large-chunk-of-entropy.patch
queue-4.19/random-avoid-checking-crng_ready-twice-in-random_init.patch
queue-4.19/random-group-sysctl-functions.patch
queue-4.19/random-don-t-let-644-read-only-sysctls-be-written-to.patch
queue-4.19/random-only-wake-up-writers-after-zap-if-threshold-was-passed.patch
queue-4.19/random-check-for-signal-and-try-earlier-when-generating-entropy.patch
queue-4.19/random-absorb-fast-pool-into-input-pool-after-fast-load.patch
queue-4.19/random-give-sysctl_random_min_urandom_seed-a-more-sensible-value.patch
queue-4.19/random-cleanup-fractional-entropy-shift-constants.patch
queue-4.19/random-use-rdseed-instead-of-rdrand-in-entropy-extraction.patch
queue-4.19/random-move-initialization-functions-out-of-hot-pages.patch
queue-4.19/random-use-computational-hash-for-entropy-extraction.patch
queue-4.19/random-round-robin-registers-as-ulong-not-u32.patch
queue-4.19/random-always-wake-up-entropy-writers-after-extraction.patch
queue-4.19/random-do-not-xor-rdrand-when-writing-into-dev-random.patch
queue-4.19/random-only-call-crng_finalize_init-for-primary_crng.patch
queue-4.19/random-cleanup-integer-types.patch
queue-4.19/random-re-add-removed-comment-about-get_random_-u32-u64-reseeding.patch
queue-4.19/random-unify-cycles_t-and-jiffies-usage-and-types.patch
queue-4.19/random-group-initialization-wait-functions.patch
queue-4.19/random-remove-unused-extract_entropy-reserved-argument.patch
queue-4.19/random-access-primary_pool-directly-rather-than-through-pointer.patch
queue-4.19/random-remove-unused-tracepoints.patch
queue-4.19/random-treat-bootloader-trust-toggle-the-same-way-as-cpu-trust-toggle.patch
queue-4.19/random-make-consistent-usage-of-crng_ready.patch
queue-4.19/random-check-for-signals-after-page-of-pool-writes.patch
queue-4.19/random-make-random_get_entropy-return-an-unsigned-long.patch
queue-4.19/random-check-for-crng_init-0-in-add_device_randomness.patch
queue-4.19/random-defer-fast-pool-mixing-to-worker.patch
queue-4.19/random-harmonize-crng-init-done-messages.patch
queue-4.19/random-use-static-branch-for-crng_ready.patch
queue-4.19/random-rather-than-entropy_store-abstraction-use-global.patch
queue-4.19/random-group-entropy-collection-functions.patch
queue-4.19/random-de-duplicate-input_pool-constants.patch
queue-4.19/random-mix-build-time-latent-entropy-into-pool-at-init.patch
queue-4.19/random-remove-useless-header-comment.patch
queue-4.19/random-remove-outdated-int_max-6-check-in-urandom_read.patch
queue-4.19/random-mix-bootloader-randomness-into-pool.patch
queue-4.19/random-do-not-use-batches-when-crng_ready.patch
queue-4.19/random-use-is_enabled-config_numa-instead-of-ifdefs.patch
queue-4.19/random-use-symbolic-constants-for-crng_init-states.patch
queue-4.19/random-ensure-early-rdseed-goes-through-mixer-on-init.patch
queue-4.19/random-deobfuscate-irq-u32-u64-contributions.patch
queue-4.19/random-fix-crash-on-multiple-early-calls-to-add_bootloader_randomness.patch
queue-4.19/random-remove-ratelimiting-for-in-kernel-unseeded-randomness.patch
queue-4.19/random-prepend-remaining-pool-constants-with-pool_.patch
queue-4.19/random-remove-unused-output_pool-constants.patch
queue-4.19/random-use-hash-function-for-crng_slow_load.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux