New module: subproc
diff --git a/Makefile b/Makefile
index 5660feb..995083e 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,7 @@
BIN := honggfuzz
COMMON_CFLAGS := -D_GNU_SOURCE -Wall -Werror -Wframe-larger-than=131072
COMMON_LDFLAGS := -lm
-COMMON_SRCS := honggfuzz.c cmdline.c display.c files.c fuzz.c log.c mangle.c report.c sancov.c util.c
+COMMON_SRCS := honggfuzz.c cmdline.c display.c files.c fuzz.c log.c mangle.c report.c sancov.c subproc.c util.c
OS ?= $(shell uname -s)
MARCH ?= $(shell uname -m)
diff --git a/fuzz.c b/fuzz.c
index 7e2202b..ea27444 100644
--- a/fuzz.c
+++ b/fuzz.c
@@ -592,6 +592,7 @@
}
if (hfuzz->persistent) {
+ LOG_I("Persistent mode: Launched new persistent PID: %d", (int)fuzzer->pid);
fuzzer->persistentPid = fuzzer->pid;
}
}
@@ -623,6 +624,8 @@
static void *fuzz_threadNew(void *arg)
{
+ LOG_I("Launched new fuzzing thread");
+
honggfuzz_t *hfuzz = (honggfuzz_t *) arg;
fuzzer_t fuzzer = {
diff --git a/linux/arch.c b/linux/arch.c
index 256da80..b8be492 100644
--- a/linux/arch.c
+++ b/linux/arch.c
@@ -49,12 +49,13 @@
#include <sys/types.h>
#include <sys/utsname.h>
+#include "files.h"
#include "linux/perf.h"
#include "linux/ptrace_utils.h"
#include "log.h"
#include "sancov.h"
+#include "subproc.h"
#include "util.h"
-#include "files.h"
/* Common sanitizer flags */
#if _HF_MONITOR_SIGABRT
@@ -334,6 +335,9 @@
if (hfuzz->persistent && pid == fuzzer->persistentPid
&& (WIFEXITED(status) || WIFSIGNALED(status))) {
fuzzer->persistentPid = 0;
+ char statusStr[4096];
+ LOG_W("Persistent mode: PID %d exited with status: %s", pid,
+ subproc_StatusToStr(status, statusStr, sizeof(statusStr)));
break;
}
if (ptracePid == childPid) {
diff --git a/subproc.c b/subproc.c
new file mode 100644
index 0000000..5f02592
--- /dev/null
+++ b/subproc.c
@@ -0,0 +1,83 @@
+/*
+ *
+ * honggfuzz - routines dealing with subprocesses
+ * -----------------------------------------
+ *
+ * Author:
+ * Robert Swiecki <swiecki@google.com>
+ * Felix Gröbert <groebert@google.com>
+ *
+ * Copyright 2010-2015 by Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ *
+ */
+
+#include "common.h"
+#include "subproc.h"
+
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "log.h"
+
+const char *subproc_StatusToStr(int status, char *str, size_t len)
+{
+ if (WIFEXITED(status)) {
+ snprintf(str, len, "EXITED, exit code: %d", WEXITSTATUS(status));
+ return str;
+ }
+
+ if (WIFSIGNALED(status)) {
+ snprintf(str, len, "SIGNALED, signal: %d (%s)", WTERMSIG(status),
+ strsignal(WTERMSIG(status)));
+ return str;
+ }
+
+ if (WIFCONTINUED(status)) {
+ snprintf(str, len, "CONTINUED");
+ return str;
+ }
+
+ if (!WIFSTOPPED(status)) {
+ snprintf(str, len, "UNKNOWN STATUS: %d", status);
+ return str;
+ }
+
+ /* Must be in a stopped state */
+ if (WSTOPSIG(status) == (SIGTRAP | 0x80)) {
+ snprintf(str, len, "STOPPED (linux syscall): %d (%s)", WSTOPSIG(status),
+ strsignal(WSTOPSIG(status)));
+ return str;
+ }
+#define __LINUX_WPTRACEEVENT(x) ((x & 0xff0000) >> 16)
+ if (WSTOPSIG(status) == SIGTRAP && __LINUX_WPTRACEEVENT(status) != 0) {
+ switch (__LINUX_WPTRACEEVENT(status)) {
+ case 1: /* PTRACE_EVENT_FORK */
+ snprintf(str, len, "EVENT (Linux) with signal: %d (%s)", WSTOPSIG(status),
+ strsignal(WSTOPSIG(status)));
+ return str;
+ default:
+ snprintf(str, len, "EVENT (Linux) UNKNOWN (%d): with signal: %d (%s)",
+ __LINUX_WPTRACEEVENT(status), WSTOPSIG(status), strsignal(WSTOPSIG(status)));
+ return str;
+ }
+ }
+
+ snprintf(str, len, "STOPPED with signal: %d (%s)", WSTOPSIG(status),
+ strsignal(WSTOPSIG(status)));
+ return str;
+}
diff --git a/subproc.h b/subproc.h
new file mode 100644
index 0000000..2dbee2c
--- /dev/null
+++ b/subproc.h
@@ -0,0 +1,29 @@
+/*
+ *
+ * honggfuzz - routines dealing with subprocesses
+ * -----------------------------------------
+ *
+ * Author: Robert Swiecki <swiecki@google.com>
+ *
+ * Copyright 2010-2015 by Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ *
+ */
+
+#ifndef _HF_SUBPROC_H_
+#define _HF_SUBPROC_H_
+
+extern const char *subproc_StatusToStr(int status, char *str, size_t len);
+
+#endif