Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Fix a backwards memcmp() that was causing all hardwa...
details: https://anonhg.NetBSD.org/src/rev/67d89e4826de
branches: trunk
changeset: 771416:67d89e4826de
user: tls <tls%NetBSD.org@localhost>
date: Sun Nov 20 00:28:51 2011 +0000
description:
Fix a backwards memcmp() that was causing all hardware sources to detach.
diffstat:
sys/dev/rnd.c | 35 ++++++++++++++++++++++-------------
1 files changed, 22 insertions(+), 13 deletions(-)
diffs (71 lines):
diff -r 87e339cf0beb -r 67d89e4826de sys/dev/rnd.c
--- a/sys/dev/rnd.c Sat Nov 19 22:51:18 2011 +0000
+++ b/sys/dev/rnd.c Sun Nov 20 00:28:51 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rnd.c,v 1.83 2011/11/19 22:51:22 tls Exp $ */
+/* $NetBSD: rnd.c,v 1.84 2011/11/20 00:28:51 tls Exp $ */
/*-
* Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.83 2011/11/19 22:51:22 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.84 2011/11/20 00:28:51 tls Exp $");
#include <sys/param.h>
#include <sys/ioctl.h>
@@ -954,15 +954,6 @@
LIST_REMOVE(source, list);
- if (source->state) {
- rnd_sample_free(source->state);
- source->state = NULL;
- }
-
- if (source->test) {
- kmem_free(source->test, sizeof(rngtest_t));
- }
-
/*
* If there are samples queued up "remove" them from the sample queue
* by setting the source to the no-collect pseudosource.
@@ -976,6 +967,16 @@
}
mutex_spin_exit(&rnd_mtx);
+
+ if (source->state) {
+ rnd_sample_free(source->state);
+ source->state = NULL;
+ }
+
+ if (source->test) {
+ kmem_free(source->test, sizeof(rngtest_t));
+ }
+
#ifdef RND_VERBOSE
printf("rnd: %s detached as an entropy source\n", source->name);
#endif
@@ -1133,9 +1134,17 @@
v1 = (uint8_t *)sample->values;
v2 = (uint8_t *)sample->values + cmplen;
- if (__predict_false(memcmp(v1, v2, cmplen))) {
- printf("rnd: source \"%s\" failed continuous-output test.",
+ if (__predict_false(!memcmp(v1, v2, cmplen))) {
+ int *dump;
+ printf("rnd: source \"%s\" failed continuous-output test.\n",
source->name);
+ printf("rnd: bad buffer: ");
+ for (dump = (int *)sample->values;
+ dump < (int *)((uint8_t *)sample->values +
+ sizeof(sample->values)); dump += sizeof(int)) {
+ printf("%x ", *dump);
+ }
+ printf("\n");
return 1;
}
Home |
Main Index |
Thread Index |
Old Index