aboutsummaryrefslogtreecommitdiff
path: root/tests/qtest/fuzz/fork_fuzz.h
diff options
context:
space:
mode:
authorAlexander Bulekov <alxndr@bu.edu>2020-02-19 23:11:11 -0500
committerStefan Hajnoczi <stefanha@redhat.com>2020-02-22 08:26:48 +0000
commitcb06fdad05f3e546a4e20f1f3c0127f9ae53de1a (patch)
treeb5176e5d8bb8ef7004935b8ca6cbf4c77cf5cf0e /tests/qtest/fuzz/fork_fuzz.h
parentd6919e4cb65230b0c8081eb072893d4e8a191a59 (diff)
fuzz: support for fork-based fuzzing.
fork() is a simple way to ensure that state does not leak in between fuzzing runs. Unfortunately, the fuzzer mutation engine relies on bitmaps which contain coverage information for each fuzzing run, and these bitmaps should be copied from the child to the parent(where the mutation occurs). These bitmaps are created through compile-time instrumentation and they are not shared with fork()-ed processes, by default. To address this, we create a shared memory region, adjust its size and map it _over_ the counter region. Furthermore, libfuzzer doesn't generally expose the globals that specify the location of the counters/coverage bitmap. As a workaround, we rely on a custom linker script which forces all of the bitmaps we care about to be placed in a contiguous region, which is easy to locate and mmap over. Signed-off-by: Alexander Bulekov <alxndr@bu.edu> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Darren Kenny <darren.kenny@oracle.com> Message-id: 20200220041118.23264-16-alxndr@bu.edu Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/qtest/fuzz/fork_fuzz.h')
-rw-r--r--tests/qtest/fuzz/fork_fuzz.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/qtest/fuzz/fork_fuzz.h b/tests/qtest/fuzz/fork_fuzz.h
new file mode 100644
index 0000000000..9ecb8b58ef
--- /dev/null
+++ b/tests/qtest/fuzz/fork_fuzz.h
@@ -0,0 +1,23 @@
+/*
+ * Fork-based fuzzing helpers
+ *
+ * Copyright Red Hat Inc., 2019
+ *
+ * Authors:
+ * Alexander Bulekov <alxndr@bu.edu>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef FORK_FUZZ_H
+#define FORK_FUZZ_H
+
+extern uint8_t __FUZZ_COUNTERS_START;
+extern uint8_t __FUZZ_COUNTERS_END;
+
+void counter_shm_init(void);
+
+#endif
+