Update important signals when initializing arch backend
Signed-off-by: Anestis Bechtsoudis <anestis@census-labs.com>
diff --git a/linux/arch.c b/linux/arch.c
index 9c718a9..792dbc7 100644
--- a/linux/arch.c
+++ b/linux/arch.c
@@ -445,6 +445,9 @@
hfuzz->linux.pidCmd[sz] = '\0';
}
+ /* Updates the important signal array based on input args */
+ arch_ptraceSignalsInit(hfuzz);
+
/*
* If sanitizer fuzzing enabled and SIGABRT is monitored (abort_on_error=1),
* increase number of major frames, since top 7-9 frames will be occupied
diff --git a/linux/ptrace_utils.c b/linux/ptrace_utils.c
index 4ae0168..c72a908 100644
--- a/linux/ptrace_utils.c
+++ b/linux/ptrace_utils.c
@@ -266,10 +266,12 @@
[SIGBUS].important = true,
[SIGBUS].descr = "SIGBUS",
+ /* Is affected from monitorSIGABRT flag */
[SIGABRT].important = false,
[SIGABRT].descr = "SIGABRT",
- [SIGVTALRM].important = true,
+ /* Is affected from tmout_vtalrm flag */
+ [SIGVTALRM].important = false,
[SIGVTALRM].descr = "SIGVTALRM-TMOUT",
};
/* *INDENT-ON* */
@@ -1197,8 +1199,7 @@
/*
* If it's an interesting signal, save the testcase
*/
- if (arch_sigs[WSTOPSIG(status)].important
- || (WSTOPSIG(status) == SIGABRT && hfuzz->monitorSIGABRT == true)) {
+ if (arch_sigs[WSTOPSIG(status)].important) {
/*
* If fuzzer worker is from core fuzzing process run full
* analysis. Otherwise just unwind and get stack hash signature.
@@ -1372,3 +1373,12 @@
ptrace(PTRACE_DETACH, tasks[i], NULL, NULL);
}
}
+
+void arch_ptraceSignalsInit(honggfuzz_t * hfuzz)
+{
+ /* Default is true for all platforms except Android */
+ arch_sigs[SIGABRT].important = hfuzz->monitorSIGABRT;
+
+ /* Default is false */
+ arch_sigs[SIGVTALRM].important = hfuzz->tmout_vtalrm;
+}
diff --git a/linux/ptrace_utils.h b/linux/ptrace_utils.h
index 59c217a..3a784ca 100644
--- a/linux/ptrace_utils.h
+++ b/linux/ptrace_utils.h
@@ -37,5 +37,6 @@
extern void arch_ptraceDetach(pid_t pid);
extern void arch_ptraceGetCustomPerf(honggfuzz_t * hfuzz, pid_t pid, uint64_t * cnt);
extern void arch_ptraceSetCustomPerf(honggfuzz_t * hfuzz, pid_t pid, uint64_t cnt);
+extern void arch_ptraceSignalsInit(honggfuzz_t * hfuzz);
#endif
diff --git a/mac/arch.c b/mac/arch.c
index 5111e97..2b878d2 100644
--- a/mac/arch.c
+++ b/mac/arch.c
@@ -122,9 +122,13 @@
arch_sigs[SIGSEGV].descr = "SIGSEGV";
arch_sigs[SIGBUS].important = true;
arch_sigs[SIGBUS].descr = "SIGBUS";
+
+ /* Is affected from monitorSIGABRT flag */
arch_sigs[SIGABRT].important = true;
arch_sigs[SIGABRT].descr = "SIGABRT";
- arch_sigs[SIGVTALRM].important = true;
+
+ /* Is affected from tmout_vtalrm flag */
+ arch_sigs[SIGVTALRM].important = false;
arch_sigs[SIGVTALRM].descr = "SIGVTALRM";
}
@@ -473,6 +477,12 @@
return false;
}
+ /* Default is true for all platforms except Android */
+ arch_sigs[SIGABRT].important = hfuzz->monitorSIGABRT;
+
+ /* Default is false */
+ arch_sigs[SIGVTALRM].important = hfuzz->tmout_vtalrm;
+
return true;
}
diff --git a/posix/arch.c b/posix/arch.c
index bba42ca..71b49f3 100644
--- a/posix/arch.c
+++ b/posix/arch.c
@@ -67,10 +67,12 @@
[SIGBUS].important = true,
[SIGBUS].descr = "SIGBUS",
- [SIGABRT].important = true,
+ /* Is affected from monitorSIGABRT flag */
+ [SIGABRT].important = false,
[SIGABRT].descr = "SIGABRT",
- [SIGVTALRM].important = true,
+ /* Is affected from tmout_vtalrm flag */
+ [SIGVTALRM].important = false,
[SIGVTALRM].descr = "SIGVTALRM-TMOUT",
};
/* *INDENT-ON* */
@@ -236,8 +238,14 @@
}
}
-bool arch_archInit(honggfuzz_t * hfuzz UNUSED)
+bool arch_archInit(honggfuzz_t * hfuzz)
{
+ /* Default is true for all platforms except Android */
+ arch_sigs[SIGABRT].important = hfuzz->monitorSIGABRT;
+
+ /* Default is false */
+ arch_sigs[SIGVTALRM].important = hfuzz->tmout_vtalrm;
+
return true;
}