summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormortimer <mortimer@openbsd.org>2018-02-10 02:54:33 +0000
committermortimer <mortimer@openbsd.org>2018-02-10 02:54:33 +0000
commita4349a2ed0d3eaa37016558674c5ee8cae05a8a6 (patch)
tree3d82cca4e02f9a1eec97ce9b842b4b5f78f6b98f
parentAdd prefix-sets, lists of prefixes which can be used in place of a (diff)
downloadwireguard-openbsd-a4349a2ed0d3eaa37016558674c5ee8cae05a8a6.tar.xz
wireguard-openbsd-a4349a2ed0d3eaa37016558674c5ee8cae05a8a6.zip
Use sched_pause(yield) to decide when to yield when filling randomdata.
ok deraadt@
-rw-r--r--sys/kern/exec_subr.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/sys/kern/exec_subr.c b/sys/kern/exec_subr.c
index a502b4b773c..c1924edbaab 100644
--- a/sys/kern/exec_subr.c
+++ b/sys/kern/exec_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_subr.c,v 1.53 2018/02/08 09:27:44 mortimer Exp $ */
+/* $OpenBSD: exec_subr.c,v 1.54 2018/02/10 02:54:33 mortimer Exp $ */
/* $NetBSD: exec_subr.c,v 1.9 1994/12/04 03:10:42 mycroft Exp $ */
/*
@@ -290,7 +290,7 @@ vmcmd_randomize(struct proc *p, struct exec_vmcmd *cmd)
int error;
struct arc4random_ctx *ctx;
char *buf;
- size_t count, sublen, off = 0;
+ size_t sublen, off = 0;
size_t len = cmd->ev_len;
if (len == 0)
@@ -305,7 +305,6 @@ vmcmd_randomize(struct proc *p, struct exec_vmcmd *cmd)
explicit_bzero(buf, len);
} else {
ctx = arc4random_ctx_new();
- count = 0;
do {
sublen = MIN(len, PAGE_SIZE);
arc4random_ctx_buf(ctx, buf, sublen);
@@ -314,10 +313,7 @@ vmcmd_randomize(struct proc *p, struct exec_vmcmd *cmd)
break;
off += sublen;
len -= sublen;
- if (++count == 32) {
- count = 0;
- yield();
- }
+ sched_pause(yield);
} while (len);
arc4random_ctx_free(ctx);
explicit_bzero(buf, PAGE_SIZE);