Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/common/lib/libc/misc Introduce UBSAN_ALWAYS_FATAL in micro-U...



details:   https://anonhg.NetBSD.org/src/rev/932257fb16cb
branches:  trunk
changeset: 999749:932257fb16cb
user:      kamil <kamil%NetBSD.org@localhost>
date:      Mon Jun 17 18:55:37 2019 +0000

description:
Introduce UBSAN_ALWAYS_FATAL in micro-UBSan

UBSAN_ALWAYS_FATAL is a CPP option to mark all reports fatal always.

diffstat:

 common/lib/libc/misc/ubsan.c |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (52 lines):

diff -r ded4b16f24db -r 932257fb16cb common/lib/libc/misc/ubsan.c
--- a/common/lib/libc/misc/ubsan.c      Mon Jun 17 18:36:39 2019 +0000
+++ b/common/lib/libc/misc/ubsan.c      Mon Jun 17 18:55:37 2019 +0000
@@ -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 @@
 #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 @@
 
        va_start(ap, pFormat);
 #if defined(_KERNEL)
-       if (isFatal)
+       if (isFatal || alwaysFatal)
                vpanic(pFormat, ap);
        else
                vprintf(pFormat, ap);
@@ -1190,7 +1196,7 @@
                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 */



Home | Main Index | Thread Index | Old Index