Index: sys/arch/amd64/conf/GENERIC =================================================================== RCS file: /cvsroot/src/sys/arch/amd64/conf/GENERIC,v retrieving revision 1.529 diff -u -r1.529 GENERIC --- sys/arch/amd64/conf/GENERIC 15 Jun 2019 06:40:34 -0000 1.529 +++ sys/arch/amd64/conf/GENERIC 17 Jun 2019 15:54:21 -0000 @@ -116,6 +116,7 @@ #options KGDB_DEVNAME="\"com\"",KGDB_DEVADDR=0x3f8,KGDB_DEVRATE=9600 makeoptions DEBUG="-g" # compile full symbol table for CTF #options KUBSAN # Kernel Undefined Behavior Sanitizer (kUBSan) +#options KUBSAN_PANIC # (optional) Panic on all kUBSan reports #options SYSCALL_STATS # per syscall counts #options SYSCALL_TIMES # per syscall times #options SYSCALL_TIMES_HASCOUNTER # use 'broken' rdtsc (soekris) Index: common/lib/libc/misc/ubsan.c =================================================================== RCS file: /cvsroot/src/common/lib/libc/misc/ubsan.c,v retrieving revision 1.5 diff -u -r1.5 ubsan.c --- common/lib/libc/misc/ubsan.c 13 Feb 2019 17:17:02 -0000 1.5 +++ common/lib/libc/misc/ubsan.c 17 Jun 2019 15:54:21 -0000 @@ -79,6 +79,12 @@ #define CLR(t, f) ((t) &= ~(f)) #endif +#ifdef KUBSAN_PANIC +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 */