Source-Changes-HG archive

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

[src/trunk]: src/sys/kern entropy(9): Make rnd_lock_sources work while cold.



details:   https://anonhg.NetBSD.org/src/rev/c793f03e0c61
branches:  trunk
changeset: 364402:c793f03e0c61
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Mar 21 00:25:04 2022 +0000

description:
entropy(9): Make rnd_lock_sources work while cold.

x86 uses entropy_extract verrrrrry early.  Fixes mistake in previous
that did not manifest in my testing on aarch64, which does not use it
so early.

diffstat:

 sys/kern/kern_entropy.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r 48ec5dd4d4db -r c793f03e0c61 sys/kern/kern_entropy.c
--- a/sys/kern/kern_entropy.c   Sun Mar 20 20:37:59 2022 +0000
+++ b/sys/kern/kern_entropy.c   Mon Mar 21 00:25:04 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_entropy.c,v 1.50 2022/03/20 18:19:58 riastradh Exp $      */
+/*     $NetBSD: kern_entropy.c,v 1.51 2022/03/21 00:25:04 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.50 2022/03/20 18:19:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_entropy.c,v 1.51 2022/03/21 00:25:04 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -1698,9 +1698,10 @@
 {
        int error;
 
-       KASSERT(mutex_owned(&E->lock));
+       KASSERT(E->stage == ENTROPY_COLD || mutex_owned(&E->lock));
 
        while (E->sourcelock) {
+               KASSERT(E->stage >= ENTROPY_WARM);
                if (!ISSET(flags, ENTROPY_WAIT))
                        return EWOULDBLOCK;
                if (ISSET(flags, ENTROPY_SIG)) {



Home | Main Index | Thread Index | Old Index