diff options
| author | kamil <kamil@NetBSD.org> | 2019-06-17 18:55:37 +0000 |
|---|---|---|
| committer | kamil <kamil@NetBSD.org> | 2019-06-17 18:55:37 +0000 |
| commit | b47bb88db80bbf9475e4c3fa210af21704415787 (patch) | |
| tree | 132066eb02cafc89ff3813e4615ffd0c63d30d93 /common | |
| parent | 478f4450d4b38518efc355ccc703724e83a3674b (diff) | |
Introduce UBSAN_ALWAYS_FATAL in micro-UBSan
UBSAN_ALWAYS_FATAL is a CPP option to mark all reports fatal always.
Diffstat (limited to 'common')
| -rw-r--r-- | common/lib/libc/misc/ubsan.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/common/lib/libc/misc/ubsan.c b/common/lib/libc/misc/ubsan.c index 24cfb5cba21..42a76f0337d 100644 --- a/common/lib/libc/misc/ubsan.c +++ b/common/lib/libc/misc/ubsan.c @@ -1,4 +1,4 @@ -/* $NetBSD: ubsan.c,v 1.5 2019/02/13 17:17:02 kamil Exp $ */ +/* $NetBSD: ubsan.c,v 1.6 2019/06/17 18:55:37 kamil Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -38,9 +38,9 @@ #include <sys/cdefs.h> #if defined(_KERNEL) -__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.5 2019/02/13 17:17:02 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ubsan.c,v 1.6 2019/06/17 18:55:37 kamil Exp $"); #else -__RCSID("$NetBSD: ubsan.c,v 1.5 2019/02/13 17:17:02 kamil Exp $"); +__RCSID("$NetBSD: ubsan.c,v 1.6 2019/06/17 18:55:37 kamil Exp $"); #endif #if defined(_KERNEL) @@ -79,6 +79,12 @@ __RCSID("$NetBSD: ubsan.c,v 1.5 2019/02/13 17:17:02 kamil Exp $"); #define CLR(t, f) ((t) &= ~(f)) #endif +#ifdef UBSAN_ALWAYS_FATAL +static const bool alwaysFatal = true; +#else +static const bool alwaysFatal = false; +#endif + #define REINTERPRET_CAST(__dt, __st) ((__dt)(__st)) #define STATIC_CAST(__dt, __st) ((__dt)(__st)) @@ -1122,7 +1128,7 @@ Report(bool isFatal, const char *pFormat, ...) va_start(ap, pFormat); #if defined(_KERNEL) - if (isFatal) + if (isFatal || alwaysFatal) vpanic(pFormat, ap); else vprintf(pFormat, ap); @@ -1190,7 +1196,7 @@ Report(bool isFatal, const char *pFormat, ...) ubsan_vsyslog(LOG_DEBUG | LOG_USER, &SyslogData, pFormat, tmp); va_end(tmp); } - if (isFatal || ISSET(ubsan_flags, UBSAN_ABORT)) { + if (isFatal || alwaysFatal || ISSET(ubsan_flags, UBSAN_ABORT)) { abort(); __unreachable(); /* NOTREACHED */ |
