summaryrefslogtreecommitdiffstats
path: root/sys/dev/kcov.c
diff options
context:
space:
mode:
authoranton <anton@openbsd.org>2020-05-17 08:46:05 +0000
committeranton <anton@openbsd.org>2020-05-17 08:46:05 +0000
commit30dbb8c708b8b4dae2db73c5f365bb25eb906771 (patch)
treed2cadac236cfc3b5a58ff12f58587dd7832d7fab /sys/dev/kcov.c
parentfix typo in a comment (diff)
downloadwireguard-openbsd-30dbb8c708b8b4dae2db73c5f365bb25eb906771.tar.xz
wireguard-openbsd-30dbb8c708b8b4dae2db73c5f365bb25eb906771.zip
Prevent kcov from collecting coverage after the kernel has panicked.
This could happen if curproc had kcov enabled while panicking. ok mpi@ visa@
Diffstat (limited to 'sys/dev/kcov.c')
-rw-r--r--sys/dev/kcov.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/dev/kcov.c b/sys/dev/kcov.c
index 7e7c5108737..fa1ce1b6dc5 100644
--- a/sys/dev/kcov.c
+++ b/sys/dev/kcov.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kcov.c,v 1.17 2020/05/16 08:38:34 anton Exp $ */
+/* $OpenBSD: kcov.c,v 1.18 2020/05/17 08:46:05 anton Exp $ */
/*
* Copyright (c) 2018 Anton Lindqvist <anton@openbsd.org>
@@ -387,6 +387,13 @@ kd_curproc(int mode)
struct kcov_dev *kd;
/*
+ * Do not trace if the kernel has panicked. This could happen if curproc
+ * had kcov enabled while panicking.
+ */
+ if (__predict_false(panicstr || db_active))
+ return (NULL);
+
+ /*
* Do not trace before kcovopen() has been called at least once.
* At this point, all secondary CPUs have booted and accessing curcpu()
* is safe.