]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
ubsan: Introduce CONFIG_UBSAN_FATAL to panic on UBSAN failure
authorMichal Orzel <michal.orzel@amd.com>
Mon, 27 Nov 2023 14:41:55 +0000 (15:41 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 5 Dec 2023 17:59:32 +0000 (17:59 +0000)
Introduce the CONFIG_UBSAN_FATAL option to cater to scenarios where prompt
attention to undefined behavior issues, notably during CI test runs, is
essential. When enabled, this option causes Xen to panic upon detecting
UBSAN failure (as the last step in ubsan_epilogue()).

Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/Kconfig.debug
xen/common/ubsan/ubsan.c

index 94e818ee09b59e8f832cdc126c2a363b30729447..e19e9d48817ccdb5acfb4f15fa9ab3bd92c4e665 100644 (file)
@@ -107,6 +107,13 @@ config UBSAN
 
          If unsure, say N here.
 
+config UBSAN_FATAL
+       bool "Panic on UBSAN failure"
+       depends on UBSAN
+       help
+         Enabling this option will cause Xen to panic when an undefined behavior
+         is detected by UBSAN. If unsure, say N here.
+
 config DEBUG_TRACE
        bool "Debug trace support"
        ---help---
index a3a80fa99eecc3b0b9867c643efc7ab4d53afbd8..5d50c107426f60fd82343a027128f0385e989a53 100644 (file)
@@ -174,6 +174,9 @@ static void ubsan_epilogue(unsigned long *flags)
                "========================================\n");
        spin_unlock_irqrestore(&report_lock, *flags);
        current->in_ubsan--;
+
+       if (IS_ENABLED(CONFIG_UBSAN_FATAL))
+           panic("UBSAN failure detected\n");
 }
 
 static void handle_overflow(struct overflow_data *data, unsigned long lhs,