mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Subject: [PATCH v2 08/10] sandbox: use sanitizer unwind for dump_stack if available
Date: Tue, 27 Aug 2019 17:09:16 +0200	[thread overview]
Message-ID: <20190827150918.16247-9-ahmad@a3f.at> (raw)
In-Reply-To: <20190827150918.16247-1-ahmad@a3f.at>

The sanitize unwind looks pretty and is just a function call away if we
are compiling with KASAN or UBSAN. Use it if available.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 arch/sandbox/Kconfig      |  6 ++++++
 arch/sandbox/Makefile     |  2 +-
 arch/sandbox/lib/Makefile |  1 +
 arch/sandbox/lib/unwind.c | 11 +++++++++++
 4 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 arch/sandbox/lib/Makefile
 create mode 100644 arch/sandbox/lib/unwind.c

diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index d153846efa0f..1171e4b8f8e3 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -12,3 +12,9 @@ config LINUX
 	bool
 	default y
 	select GENERIC_FIND_NEXT_BIT
+
+config SANDBOX_UNWIND
+	bool
+	default y
+	select ARCH_HAS_STACK_DUMP
+	depends on UBSAN || KASAN
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index 780783a1e08c..62f6be745a76 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -51,7 +51,7 @@ cmd_barebox__ = $(CC) -o $@ -Wl,-T,$(barebox-lds) \
 	-Wl,--start-group $(barebox-common) -Wl,--end-group \
 	-lrt -lpthread $(SDL_LIBS) $(FTDI1_LIBS)
 
-common-y += $(BOARD) arch/sandbox/os/
+common-y += $(BOARD) arch/sandbox/os/ arch/sandbox/lib/
 
 common-$(CONFIG_OFTREE) += arch/sandbox/dts/
 
diff --git a/arch/sandbox/lib/Makefile b/arch/sandbox/lib/Makefile
new file mode 100644
index 000000000000..b32ca6aaf804
--- /dev/null
+++ b/arch/sandbox/lib/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_ARCH_HAS_STACK_DUMP) += unwind.o
diff --git a/arch/sandbox/lib/unwind.c b/arch/sandbox/lib/unwind.c
new file mode 100644
index 000000000000..15a2798cc404
--- /dev/null
+++ b/arch/sandbox/lib/unwind.c
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// Copyright 2019 Ahmad Fatoum
+
+#include <common.h>
+
+void __sanitizer_print_stack_trace(void);
+
+void dump_stack(void)
+{
+		__sanitizer_print_stack_trace();
+}
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2019-08-27 15:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 15:09 [PATCH v2 00/10] Add initial support for -fsanitize={ubsan,asan} Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 01/10] Kconfig: create Kconfig symbol for ARCH_HAS_STACK_DUMP Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 02/10] Kconfig: create Kconfig symbol for ARCH_HAS_DATA_ABORT_MASK Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 03/10] blackfin: delete unused <asm/barebox.h> definitions Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 04/10] Kconfig: retire empty <asm/barebox.h> Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 05/10] lib: add HAVE_EFFICIENT_UNALIGNED_ACCESS Kconfig option Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 06/10] common: add generic CONFIG_UBSAN plumbing Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 07/10] commands: add intentionally UB triggering ubsan command Ahmad Fatoum
2019-08-27 15:09 ` Ahmad Fatoum [this message]
2019-08-27 15:09 ` [PATCH v2 09/10] common: add generic CONFIG_KASAN option Ahmad Fatoum
2019-08-27 15:09 ` [PATCH v2 10/10] sandbox: support Address and UndefinedBehavior sanitizers Ahmad Fatoum
2019-09-04  6:53 ` [PATCH v2 00/10] Add initial support for -fsanitize={ubsan,asan} Sascha Hauer
2019-09-04  7:52   ` Ahmad Fatoum
2019-09-05  6:02     ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190827150918.16247-9-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox