Source-Changes-HG archive

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

[src/trunk]: src/sys/crypto/cprng_fast cprng_fast(9): Assert not in pserializ...



details:   https://anonhg.NetBSD.org/src/rev/f5e006c79b6b
branches:  trunk
changeset: 369807:f5e006c79b6b
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Sep 01 18:32:25 2022 +0000

description:
cprng_fast(9): Assert not in pserialize read section.

This may sleep to take the global entropy lock in case it needs to be
reseeded.  If that happens we can't be in a pserialize read section.

diffstat:

 sys/crypto/cprng_fast/cprng_fast.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (34 lines):

diff -r 36f0d79351fe -r f5e006c79b6b sys/crypto/cprng_fast/cprng_fast.c
--- a/sys/crypto/cprng_fast/cprng_fast.c        Thu Sep 01 18:32:17 2022 +0000
+++ b/sys/crypto/cprng_fast/cprng_fast.c        Thu Sep 01 18:32:25 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cprng_fast.c,v 1.17 2022/06/01 15:44:37 riastradh Exp $        */
+/*     $NetBSD: cprng_fast.c,v 1.18 2022/09/01 18:32:25 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cprng_fast.c,v 1.17 2022/06/01 15:44:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cprng_fast.c,v 1.18 2022/09/01 18:32:25 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -41,6 +41,7 @@
 #include <sys/evcnt.h>
 #include <sys/kmem.h>
 #include <sys/percpu.h>
+#include <sys/pserialize.h>
 
 #include <crypto/chacha/chacha.h>
 
@@ -95,6 +96,7 @@
        int s;
 
        KASSERT(!cpu_intr_p());
+       KASSERT(pserialize_not_in_read_section());
 
        *cprngp = cprng = percpu_getref(cprng_fast_percpu);
        s = splsoftserial();



Home | Main Index | Thread Index | Old Index