summaryrefslogtreecommitdiffstats
path: root/debuggerd
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2016-05-10 13:29:58 -0700
committerElliott Hughes <enh@google.com>2016-05-10 14:44:59 -0700
commit23d1cad9e0ea8386cb1b23175233a13c62e41f57 (patch)
treee0d5a9391f3da36cd1a45a7cfa13ab5a998d89d4 /debuggerd
parentc5016de66b6d778dd7c292e215aad6b5c079e92c (diff)
downloadcore-23d1cad9e0ea8386cb1b23175233a13c62e41f57.tar.gz
core-23d1cad9e0ea8386cb1b23175233a13c62e41f57.tar.bz2
core-23d1cad9e0ea8386cb1b23175233a13c62e41f57.zip
Add a fortify test to crasher.
Change-Id: I675dbeaa39529583be5877946fd38b94ec341315
Diffstat (limited to 'debuggerd')
-rw-r--r--debuggerd/Android.mk6
-rw-r--r--debuggerd/crasher.cpp (renamed from debuggerd/crasher.c)12
2 files changed, 12 insertions, 6 deletions
diff --git a/debuggerd/Android.mk b/debuggerd/Android.mk
index 6469db451..9ce94c5db 100644
--- a/debuggerd/Android.mk
+++ b/debuggerd/Android.mk
@@ -54,7 +54,7 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
-LOCAL_SRC_FILES := crasher.c
+LOCAL_SRC_FILES := crasher.cpp
LOCAL_SRC_FILES_arm := arm/crashglue.S
LOCAL_SRC_FILES_arm64 := arm64/crashglue.S
LOCAL_SRC_FILES_mips := mips/crashglue.S
@@ -63,9 +63,9 @@ LOCAL_SRC_FILES_x86 := x86/crashglue.S
LOCAL_SRC_FILES_x86_64 := x86_64/crashglue.S
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_MODULE_TAGS := optional
-LOCAL_CFLAGS += -fstack-protector-all -Werror -Wno-free-nonheap-object -Wno-date-time
+LOCAL_CPPFLAGS := $(common_cppflags) -fstack-protector-all -Wno-free-nonheap-object -Wno-date-time
#LOCAL_FORCE_STATIC_EXECUTABLE := true
-LOCAL_SHARED_LIBRARIES := libcutils liblog libc
+LOCAL_SHARED_LIBRARIES := libcutils liblog
# The arm emulator has VFP but not VFPv3-D32.
ifeq ($(ARCH_ARM_HAVE_VFP_D32),true)
diff --git a/debuggerd/crasher.c b/debuggerd/crasher.cpp
index 75f070b58..bdeaf0b33 100644
--- a/debuggerd/crasher.c
+++ b/debuggerd/crasher.cpp
@@ -22,8 +22,9 @@
extern const char* __progname;
-void crash1(void);
-void crashnostack(void);
+extern "C" void crash1(void);
+extern "C" void crashnostack(void);
+
static int do_action(const char* arg);
static void maybe_abort() {
@@ -159,6 +160,10 @@ static int do_action(const char* arg)
__assert("some_file.c", 123, "false");
} else if (!strcmp(arg, "assert2")) {
__assert2("some_file.c", 123, "some_function", "false");
+ } else if (!strcmp(arg, "fortify")) {
+ char buf[10];
+ __read_chk(-1, buf, 32, 10);
+ while (true) pause();
} else if (!strcmp(arg, "LOG_ALWAYS_FATAL")) {
LOG_ALWAYS_FATAL("hello %s", "world");
} else if (!strcmp(arg, "LOG_ALWAYS_FATAL_IF")) {
@@ -172,7 +177,7 @@ static int do_action(const char* arg)
} else if (!strcmp(arg, "heap-usage")) {
abuse_heap();
} else if (!strcmp(arg, "SIGSEGV-unmapped")) {
- char* map = mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+ char* map = reinterpret_cast<char*>(mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0));
munmap(map, sizeof(int));
map[0] = '8';
}
@@ -189,6 +194,7 @@ static int do_action(const char* arg)
fprintf(stderr, " abort call abort()\n");
fprintf(stderr, " assert call assert() without a function\n");
fprintf(stderr, " assert2 call assert() with a function\n");
+ fprintf(stderr, " fortify fail a _FORTIFY_SOURCE check\n");
fprintf(stderr, " LOG_ALWAYS_FATAL call LOG_ALWAYS_FATAL\n");
fprintf(stderr, " LOG_ALWAYS_FATAL_IF call LOG_ALWAYS_FATAL\n");
fprintf(stderr, " SIGFPE cause a SIGFPE\n");