mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 4/4] sandbox: reinstate cooked terminal mode on sanitizer-induced death
Date: Mon,  6 Jul 2020 08:28:06 +0200	[thread overview]
Message-ID: <20200706062805.26278-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20200706062805.26278-1-a.fatoum@pengutronix.de>

If we exit due to AddressSanitizer error, we remain in raw mode, which
is not best user experience. Currently every exit is an AddressSanitizer
death due to leaks. We want to encourage users to always have ASan
enabled, to catch more errors, thus call cookmode() on exit.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/os/Makefile | 4 ++++
 arch/sandbox/os/common.c | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/arch/sandbox/os/Makefile b/arch/sandbox/os/Makefile
index 1d32a197ead4..f307e6a828c1 100644
--- a/arch/sandbox/os/Makefile
+++ b/arch/sandbox/os/Makefile
@@ -6,6 +6,10 @@ KBUILD_CPPFLAGS = $(patsubst %,-I$(srctree)/%include,$(machdirs))
 
 KBUILD_CPPFLAGS += -DCONFIG_MALLOC_SIZE=$(CONFIG_MALLOC_SIZE)
 
+ifeq ($(CONFIG_KASAN),y)
+KBUILD_CPPFLAGS += -DCONFIG_KASAN=1
+endif
+
 KBUILD_CFLAGS := -Wall
 NOSTDINC_FLAGS :=
 
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 534571c0e668..69fadb3b47a4 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -44,6 +44,8 @@
 #include <mach/linux.h>
 #include <mach/hostfile.h>
 
+void __sanitizer_set_death_callback(void (*callback)(void));
+
 int sdl_xres;
 int sdl_yres;
 
@@ -345,6 +347,10 @@ int main(int argc, char *argv[])
 	int fdno = 0, envno = 0, option_index = 0;
 	char *aux;
 
+#ifdef CONFIG_KASAN
+	__sanitizer_set_death_callback(cookmode);
+#endif
+
 	while (1) {
 		option_index = 0;
 		opt = getopt_long(argc, argv, optstring,
-- 
2.27.0


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

  parent reply	other threads:[~2020-07-06  6:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06  6:28 [PATCH 1/4] sandbox: include: <asm/types.h>: don't define INTERNAL_SIZE_T Ahmad Fatoum
2020-07-06  6:28 ` [PATCH 2/4] sandbox: os: common: fix compiler warning in add_image() Ahmad Fatoum
2020-07-06  6:28 ` [PATCH 3/4] sandbox: add libc memory allocator Ahmad Fatoum
2020-07-06  6:28 ` Ahmad Fatoum [this message]
2020-07-11  4:34 ` [PATCH 1/4] sandbox: include: <asm/types.h>: don't define INTERNAL_SIZE_T 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=20200706062805.26278-4-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --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