From: claudio Date: Tue, 4 Jun 2024 08:26:11 +0000 (+0000) Subject: In dequeue_randomness() use an atomic instruction to increase the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=609c45bc8afc0c1dfc2445e8ad7a99d5231f511c;p=openbsd In dequeue_randomness() use an atomic instruction to increase the rnd_event_cons. This way even concurrent calls to dequeue_randomness() will use some different events. OK deraadt@ djm@ --- diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index 9bce17cc9c8..483ee30a2d4 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.226 2023/03/08 04:43:08 guenther Exp $ */ +/* $OpenBSD: rnd.c,v 1.227 2024/06/04 08:26:11 claudio Exp $ */ /* * Copyright (c) 2011,2020 Theo de Raadt. @@ -261,7 +261,7 @@ dequeue_randomness(void *v) add_entropy_words(buf, 2); } /* and some probably more damaged */ - startc = rnd_event_cons; + startc = atomic_add_int_nv(&rnd_event_cons, QEVCONSUME) - QEVCONSUME; for (i = 0; i < QEVCONSUME; i++) { u_int e = (startc + i) & (QEVLEN-1); @@ -269,7 +269,6 @@ dequeue_randomness(void *v) buf[1] = rnd_event_space[e].re_val; add_entropy_words(buf, 2); } - rnd_event_cons = startp + QEVCONSUME; } /*