summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorcheloha <cheloha@openbsd.org>2020-09-22 13:43:28 +0000
committercheloha <cheloha@openbsd.org>2020-09-22 13:43:28 +0000
commit1cc52d09abbbdf7c670b49a4d86e33276dea30a8 (patch)
tree873e0bcf3e9a1eb210bbf22827521a42c41a23b2 /sys/kern
parentreword ambiguous title line; (diff)
downloadwireguard-openbsd-1cc52d09abbbdf7c670b49a4d86e33276dea30a8.tar.xz
wireguard-openbsd-1cc52d09abbbdf7c670b49a4d86e33276dea30a8.zip
timeout(9): timeout_run(): read to_process before leaving timeout_mutex
to_process is assigned during timeout_add(9) within timeout_mutex. In timeout_run() we need to read to_process before leaving timeout_mutex to ensure that the process pointer given to kcov_remote_enter(9) is the same as the one we set from timeout_add(9) when the candidate timeout was originally scheduled to run.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_timeout.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c
index 47bee83652e..530ecb7f670 100644
--- a/sys/kern/kern_timeout.c
+++ b/sys/kern/kern_timeout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_timeout.c,v 1.79 2020/08/07 00:45:25 cheloha Exp $ */
+/* $OpenBSD: kern_timeout.c,v 1.80 2020/09/22 13:43:28 cheloha Exp $ */
/*
* Copyright (c) 2001 Thomas Nordin <nordin@openbsd.org>
* Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org>
@@ -470,11 +470,13 @@ timeout_run(struct timeout *to)
fn = to->to_func;
arg = to->to_arg;
needsproc = ISSET(to->to_flags, TIMEOUT_PROC);
+#if NKCOV > 0
+ struct process *kcov_process = to->to_process;
+#endif
mtx_leave(&timeout_mutex);
timeout_sync_enter(needsproc);
#if NKCOV > 0
- struct process *kcov_process = to->to_process;
kcov_remote_enter(KCOV_REMOTE_COMMON, kcov_process);
#endif
fn(arg);