summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranton <anton@openbsd.org>2019-11-06 19:16:48 +0000
committeranton <anton@openbsd.org>2019-11-06 19:16:48 +0000
commitaafc92f8d3b3c43de95f63fa6540e5afadba6398 (patch)
tree0a11d92e066af2c09237e463292efb9326a1c0c0
parentPerform contraint validation against 9.9.9.9 and 2620:fe::fe also (which (diff)
downloadwireguard-openbsd-aafc92f8d3b3c43de95f63fa6540e5afadba6398.tar.xz
wireguard-openbsd-aafc92f8d3b3c43de95f63fa6540e5afadba6398.zip
Use atomic operations consistently while writing to kubsan_slot.
Otherwise, reports might go by unnoticed. Prodded by and ok visa@
-rw-r--r--sys/kern/subr_kubsan.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/kern/subr_kubsan.c b/sys/kern/subr_kubsan.c
index 3776f48560a..9655500288d 100644
--- a/sys/kern/subr_kubsan.c
+++ b/sys/kern/subr_kubsan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_kubsan.c,v 1.11 2019/11/04 17:51:22 anton Exp $ */
+/* $OpenBSD: subr_kubsan.c,v 1.12 2019/11/06 19:16:48 anton Exp $ */
/*
* Copyright (c) 2019 Anton Lindqvist <anton@openbsd.org>
@@ -708,11 +708,11 @@ again:
}
/* New reports can arrive at any time. */
- if (nslots != kubsan_slot && nslots < KUBSAN_NSLOTS)
- goto again;
-
- kubsan_slot = 0;
- membar_producer();
+ if (atomic_cas_uint(&kubsan_slot, nslots, 0) != nslots) {
+ if (nslots < KUBSAN_NSLOTS)
+ goto again;
+ atomic_swap_uint(&kubsan_slot, 0);
+ }
done:
timeout_add_msec(&kubsan_timo, KUBSAN_INTERVAL);