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

[PATCH] ubsan: Introduce CONFIG_UBSAN_FATAL to panic on UBSAN failure


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 27 Nov 2023 15:41:55 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8txgQdFFbhv199fN7KInBreuwQAnXt3XT1taWmKNQHU=; b=Zu6ATWllDw9+ywg0Vu6ZD2xKMVeto7sfJ1nwdOSelHkO00hVOuQsJLWu6URMUFE0yXtc1l966eKF0vxsYhoabkRgaGmJjXrsRe1V90ZANixgROScD48JJRgB/WHejJLyaQMEHJ/r/iOGvwZqFy+w44s77tMM1YkxKGpqWs+/Q4MwIakvr1j90UEvwxq6Q4f3UqZsaNMsvDobDW+NwrRnF8kv8bGH7X0VYC54u6EpJTp/9NpkpAvVlvvCX6newlrWsTp9wP9whDUhVMSEvYXISRb1tPBFAHTh6iyX4C+kCXsSv6K+ya3e1Wwd5jOmPnwkpq9c8YmXAjMCyYbaNhBKaw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TCOz8QhntX6ZgEuNVIAQkDJWNanWm+gkue9dpazBrUT/SVKIt9gQwwsMCZYF7IJb80iN6ORNUmFP59Db6oF7P57j8PNCkPdpBe3/reA20LNkXnTlE4CV9f+Za5qGje3JloSlrLbvovd05eAYsAmLNy5uz11Zqbnmr70hDPhwjcgU3qMHNHSc6BeqP2mnQNhEXsvbZxc7fr9ZESYfqPopVI3yStu2TpT/hHPMG53hh8s0e8LAAUlfv6nps9DdIImq8r3kucjfZ66pgwsUjpCr1wEgkfO2IVbOu6Byq/zQmEgAmNaSnuO4Lz6hbi7vJ0s2jhLj9nR4FSaUFILH5PL9nw==
  • Cc: Michal Orzel <michal.orzel@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 27 Nov 2023 14:42:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxx>
---
 xen/Kconfig.debug        | 7 +++++++
 xen/common/ubsan/ubsan.c | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug
index 94e818ee09b5..e19e9d48817c 100644
--- a/xen/Kconfig.debug
+++ b/xen/Kconfig.debug
@@ -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---
diff --git a/xen/common/ubsan/ubsan.c b/xen/common/ubsan/ubsan.c
index a3a80fa99eec..dd5ee0013648 100644
--- a/xen/common/ubsan/ubsan.c
+++ b/xen/common/ubsan/ubsan.c
@@ -174,6 +174,10 @@ static void ubsan_epilogue(unsigned long *flags)
                "========================================\n");
        spin_unlock_irqrestore(&report_lock, *flags);
        current->in_ubsan--;
+
+#ifdef CONFIG_UBSAN_FATAL
+       panic("UBSAN failure detected\n");
+#endif
 }
 
 static void handle_overflow(struct overflow_data *data, unsigned long lhs,
-- 
2.25.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.