summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-07-06 08:28:06 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-07-14 20:28:09 +0200
commit634b8a68b12de0c76a63763bb2fcb53558cd9e44 (patch)
treec7ab3db40adba25c99bca9ffb4cdee26318869f6
parent94fb245bd6946b24639e5c374b36bc41d8833fdb (diff)
downloadbarebox-634b8a68b12de0c76a63763bb2fcb53558cd9e44.tar.gz
barebox-634b8a68b12de0c76a63763bb2fcb53558cd9e44.tar.xz
sandbox: reinstate cooked terminal mode on sanitizer-induced death
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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/sandbox/os/Makefile4
-rw-r--r--arch/sandbox/os/common.c6
2 files changed, 10 insertions, 0 deletions
diff --git a/arch/sandbox/os/Makefile b/arch/sandbox/os/Makefile
index df6d597e78..28ecc093af 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 534571c0e6..69fadb3b47 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,