Module Name: src
Committed By: riastradh
Date: Mon Aug 26 13:46:51 UTC 2024
Modified Files:
src/sys/dev: random.c
Log Message:
/dev/random: Fix two signal bugs.
1. If a long write to /dev/random is interrupted by a signal, it may
proceed to sleep on the entropy source lock instead of returning
promptly.
=> Don't try to consolidate entropy if we've already been
interrupted by a signal.
2. If a write to /dev/random is interrupted by a signal while
sleeping on the entropy source lock, it may fail to report EINTR.
=> Pass through EINTR from entropy consolidation via new
entropy_consolidate_sig function.
PR kern/58646: /dev/random, kern.entropy.*: signal bugs
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/random.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/random.c
diff -u src/sys/dev/random.c:1.10 src/sys/dev/random.c:1.11
--- src/sys/dev/random.c:1.10 Tue Dec 28 13:22:43 2021
+++ src/sys/dev/random.c Mon Aug 26 13:46:51 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: random.c,v 1.10 2021/12/28 13:22:43 riastradh Exp $ */
+/* $NetBSD: random.c,v 1.11 2024/08/26 13:46:51 riastradh Exp $ */
/*-
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: random.c,v 1.10 2021/12/28 13:22:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: random.c,v 1.11 2024/08/26 13:46:51 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -298,8 +298,8 @@ random_write(dev_t dev, struct uio *uio,
kmem_free(buf, RANDOM_BUFSIZE);
/* If we added anything, consolidate entropy now. */
- if (any)
- entropy_consolidate();
+ if (any && error == 0)
+ error = entropy_consolidate_sig();
return error;
}