diff options
author | anton <anton@cvs.openbsd.org> | 2020-05-17 08:46:06 +0000 |
---|---|---|
committer | anton <anton@cvs.openbsd.org> | 2020-05-17 08:46:06 +0000 |
commit | 1d3ba9a09d8db1e74832debcc667231208be6f74 (patch) | |
tree | 7a03d6326e1a5eef22a89f14341e759d40eab306 | |
parent | 8e8ea90cfea36b0dff6b001c58888270d7986641 (diff) |
Prevent kcov from collecting coverage after the kernel has panicked.
This could happen if curproc had kcov enabled while panicking.
ok mpi@ visa@
-rw-r--r-- | sys/dev/kcov.c | 9 |
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. |