robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 1 | /* |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 2 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 3 | * honggfuzz - core structures and macros |
| 4 | * ----------------------------------------- |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 5 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 6 | * Author: Robert Swiecki <swiecki@google.com> |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 7 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 8 | * Copyright 2010-2015 by Google Inc. All Rights Reserved. |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 9 | * |
| 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 11 | * not use this file except in compliance with the License. You may obtain |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 12 | * a copy of the License at |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 13 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 15 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 16 | * Unless required by applicable law or agreed to in writing, software |
| 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 19 | * implied. See the License for the specific language governing |
| 20 | * permissions and limitations under the License. |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 21 | * |
robert.swiecki@gmail.com | 772b33d | 2015-02-14 20:35:00 +0000 | [diff] [blame] | 22 | */ |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 23 | |
Jagger | 876a74c | 2016-02-09 22:09:11 +0100 | [diff] [blame] | 24 | #ifndef _HF_COMMON_H_ |
| 25 | #define _HF_COMMON_H_ |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 26 | |
robert.swiecki@gmail.com | ba85c3e | 2015-02-02 14:55:16 +0000 | [diff] [blame] | 27 | #include <limits.h> |
robert.swiecki@gmail.com | 41d8e05 | 2015-02-19 01:10:41 +0000 | [diff] [blame] | 28 | #include <pthread.h> |
Robert Swiecki | 846ccd7 | 2017-01-12 17:52:23 +0100 | [diff] [blame] | 29 | #include <inttypes.h> |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 30 | #include <stdbool.h> |
| 31 | #include <stdint.h> |
robert.swiecki@gmail.com | ba85c3e | 2015-02-02 14:55:16 +0000 | [diff] [blame] | 32 | #include <sys/param.h> |
Robert Swiecki | 3bfc33c | 2016-03-14 18:12:41 +0100 | [diff] [blame] | 33 | #include <sys/queue.h> |
robert.swiecki@gmail.com | ba85c3e | 2015-02-02 14:55:16 +0000 | [diff] [blame] | 34 | #include <sys/types.h> |
Robert Swiecki | 64d7425 | 2016-03-31 17:28:56 +0200 | [diff] [blame] | 35 | #include <time.h> |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 36 | |
Anestis Bechtsoudis | 2ff92d1 | 2015-12-20 15:33:20 +0200 | [diff] [blame] | 37 | #ifndef UNUSED |
| 38 | #define UNUSED __attribute__((unused)) |
| 39 | #endif |
| 40 | |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 41 | #define PROG_NAME "honggfuzz" |
Jagger | e7af11e | 2016-09-27 10:06:22 +0200 | [diff] [blame] | 42 | #define PROG_VERSION "0.9alpha" |
robert.swiecki | 32b69c9 | 2015-02-26 14:56:36 +0000 | [diff] [blame] | 43 | #define PROG_AUTHORS "Robert Swiecki <swiecki@google.com> et al.,\nCopyright 2010-2015 by Google Inc. All Rights Reserved." |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 44 | |
Robert Swiecki | a9db9dd | 2016-03-09 16:29:37 +0100 | [diff] [blame] | 45 | /* Go-style defer implementation */ |
| 46 | #define __STRMERGE(a, b) a##b |
| 47 | #define _STRMERGE(a, b) __STRMERGE(a, b) |
| 48 | |
| 49 | #ifdef __clang__ |
Jagger | 4fe1869 | 2016-04-22 23:15:07 +0200 | [diff] [blame] | 50 | static void __attribute__ ((unused)) __clang_cleanup_func(void (^*dfunc) (void)) |
Robert Swiecki | a9db9dd | 2016-03-09 16:29:37 +0100 | [diff] [blame] | 51 | { |
| 52 | (*dfunc) (); |
| 53 | } |
| 54 | |
Jagger | 4fe1869 | 2016-04-22 23:15:07 +0200 | [diff] [blame] | 55 | #define defer void (^_STRMERGE(__defer_f_, __COUNTER__))(void) __attribute__((cleanup(__clang_cleanup_func))) __attribute__((unused)) = ^ |
Robert Swiecki | a9db9dd | 2016-03-09 16:29:37 +0100 | [diff] [blame] | 56 | #else |
| 57 | #define __block |
Jagger | 4fe1869 | 2016-04-22 23:15:07 +0200 | [diff] [blame] | 58 | #define _DEFER(a, count) \ |
| 59 | auto void _STRMERGE(__defer_f_, count)(void *_defer_arg __attribute__((unused))); \ |
| 60 | int _STRMERGE(__defer_var_, count) __attribute__((cleanup(_STRMERGE(__defer_f_, count)))) __attribute__((unused)); \ |
| 61 | void _STRMERGE(__defer_f_, count)(void *_defer_arg __attribute__((unused))) |
| 62 | #define defer _DEFER(a, __COUNTER__) |
Robert Swiecki | a9db9dd | 2016-03-09 16:29:37 +0100 | [diff] [blame] | 63 | #endif |
| 64 | |
robert.swiecki@gmail.com | 64dc2a0 | 2015-02-17 22:21:30 +0000 | [diff] [blame] | 65 | /* Name of the template which will be replaced with the proper name of the file */ |
robert.swiecki@gmail.com | a0d8714 | 2015-02-14 13:11:18 +0000 | [diff] [blame] | 66 | #define _HF_FILE_PLACEHOLDER "___FILE___" |
robert.swiecki@gmail.com | 64dc2a0 | 2015-02-17 22:21:30 +0000 | [diff] [blame] | 67 | |
| 68 | /* Default name of the report created with some architectures */ |
robert.swiecki@gmail.com | e7190b9 | 2015-02-14 23:05:42 +0000 | [diff] [blame] | 69 | #define _HF_REPORT_FILE "HONGGFUZZ.REPORT.TXT" |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 70 | |
Robert Swiecki | 3f03f7e | 2016-10-03 03:11:33 +0200 | [diff] [blame] | 71 | /* Default stack-size of created threads. */ |
| 72 | #define _HF_PTHREAD_STACKSIZE (1024 * 1024 * 2) /* 2MB */ |
robert.swiecki@gmail.com | 01b6dd4 | 2015-02-16 18:11:28 +0000 | [diff] [blame] | 73 | |
Jagger | fa3544a | 2016-08-30 02:55:55 +0200 | [diff] [blame] | 74 | /* Name of envvar which indicates sequential number of fuzzer */ |
| 75 | #define _HF_THREAD_NO_ENV "HFUZZ_THREAD_NO" |
| 76 | |
Anestis Bechtsoudis | 5c86ebc | 2015-09-27 18:06:43 +0300 | [diff] [blame] | 77 | /* Number of crash verifier iterations before tag crash as stable */ |
| 78 | #define _HF_VERIFIER_ITER 5 |
| 79 | |
Anestis Bechtsoudis | c06f8b3 | 2015-12-26 14:48:05 +0200 | [diff] [blame] | 80 | /* Size (in bytes) for report data to be stored in stack before written to file */ |
| 81 | #define _HF_REPORT_SIZE 8192 |
Anestis Bechtsoudis | 0ef9000 | 2015-11-22 21:17:06 +0200 | [diff] [blame] | 82 | |
Robert Swiecki | 3bfc33c | 2016-03-14 18:12:41 +0100 | [diff] [blame] | 83 | /* Perf bitmap size */ |
Jagger | 3d97752 | 2016-08-21 19:15:59 +0200 | [diff] [blame] | 84 | #define _HF_PERF_BITMAP_SIZE_16M (1024U * 1024U * 16U) |
Robert Swiecki | badab61 | 2016-09-08 18:31:10 +0200 | [diff] [blame] | 85 | #define _HF_PERF_BITMAP_BITSZ_MASK 0x7ffffff |
Robert Swiecki | 7c2c90c | 2016-10-04 02:47:38 +0200 | [diff] [blame] | 86 | /* Maximum number of PC guards (=trace-pc-guard) we support */ |
| 87 | #define _HF_PC_GUARD_MAX (1024U * 1024U) |
Robert Swiecki | 3bfc33c | 2016-03-14 18:12:41 +0100 | [diff] [blame] | 88 | |
Jagger | d34417d | 2016-03-16 01:26:54 +0100 | [diff] [blame] | 89 | #define ARRAYSIZE(x) (sizeof(x) / sizeof(*x)) |
| 90 | |
| 91 | /* Memory barriers */ |
| 92 | #define rmb() __asm__ __volatile__("":::"memory") |
| 93 | #define wmb() __sync_synchronize() |
| 94 | |
Jagger | 9a135bb | 2016-08-21 21:37:06 +0200 | [diff] [blame] | 95 | /* FD used to pass feedback bitmap a process */ |
| 96 | #define _HF_BITMAP_FD 1022 |
| 97 | /* FD used to pass data to a persistent process */ |
| 98 | #define _HF_PERSISTENT_FD 1023 |
| 99 | |
robert.swiecki@gmail.com | cac22fd | 2015-02-19 14:03:28 +0000 | [diff] [blame] | 100 | typedef enum { |
robert.swiecki@gmail.com | 81e26dc | 2015-03-03 04:26:04 +0000 | [diff] [blame] | 101 | _HF_DYNFILE_NONE = 0x0, |
| 102 | _HF_DYNFILE_INSTR_COUNT = 0x1, |
| 103 | _HF_DYNFILE_BRANCH_COUNT = 0x2, |
Jagger | 3abc560 | 2016-02-04 00:53:43 +0100 | [diff] [blame] | 104 | _HF_DYNFILE_BTS_BLOCK = 0x8, |
| 105 | _HF_DYNFILE_BTS_EDGE = 0x10, |
Jagger | 39bd2b0 | 2016-02-04 01:16:15 +0100 | [diff] [blame] | 106 | _HF_DYNFILE_IPT_BLOCK = 0x20, |
Robert Swiecki | 60cdf52 | 2016-11-01 14:31:15 +0100 | [diff] [blame] | 107 | _HF_DYNFILE_SOFT = 0x40, |
robert.swiecki@gmail.com | cac22fd | 2015-02-19 14:03:28 +0000 | [diff] [blame] | 108 | } dynFileMethod_t; |
| 109 | |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 110 | typedef struct { |
Jagger | b409ee1 | 2015-09-09 02:02:32 +0200 | [diff] [blame] | 111 | uint64_t cpuInstrCnt; |
| 112 | uint64_t cpuBranchCnt; |
Robert Swiecki | 3bfc33c | 2016-03-14 18:12:41 +0100 | [diff] [blame] | 113 | uint64_t bbCnt; |
Robert Swiecki | ac56a50 | 2016-03-17 18:59:46 +0100 | [diff] [blame] | 114 | uint64_t newBBCnt; |
Jagger | 34789a7 | 2016-09-08 00:36:09 +0200 | [diff] [blame] | 115 | uint64_t softCntPc; |
| 116 | uint64_t softCntCmp; |
Jagger | b409ee1 | 2015-09-09 02:02:32 +0200 | [diff] [blame] | 117 | } hwcnt_t; |
| 118 | |
Anestis Bechtsoudis | a16f70f | 2016-01-03 13:03:21 +0200 | [diff] [blame] | 119 | /* Sanitizer coverage specific data structures */ |
Jagger | b409ee1 | 2015-09-09 02:02:32 +0200 | [diff] [blame] | 120 | typedef struct { |
Anestis Bechtsoudis | 56e360f | 2016-01-11 14:29:17 +0200 | [diff] [blame] | 121 | uint64_t hitBBCnt; |
| 122 | uint64_t totalBBCnt; |
Anestis Bechtsoudis | a16f70f | 2016-01-03 13:03:21 +0200 | [diff] [blame] | 123 | uint64_t dsoCnt; |
| 124 | uint64_t iDsoCnt; |
Anestis Bechtsoudis | 56e360f | 2016-01-11 14:29:17 +0200 | [diff] [blame] | 125 | uint64_t newBBCnt; |
Anestis Bechtsoudis | a16f70f | 2016-01-03 13:03:21 +0200 | [diff] [blame] | 126 | uint64_t crashesCnt; |
Anestis Bechtsoudis | be0ac7b | 2015-12-26 15:38:47 +0200 | [diff] [blame] | 127 | } sancovcnt_t; |
| 128 | |
| 129 | typedef struct { |
Anestis Bechtsoudis | a16f70f | 2016-01-03 13:03:21 +0200 | [diff] [blame] | 130 | uint32_t capacity; |
| 131 | uint32_t *pChunks; |
| 132 | uint32_t nChunks; |
| 133 | } bitmap_t; |
| 134 | |
| 135 | /* Memory map struct */ |
| 136 | typedef struct __attribute__ ((packed)) { |
| 137 | uint64_t start; // region start addr |
| 138 | uint64_t end; // region end addr |
| 139 | uint64_t base; // region base addr |
| 140 | char mapName[NAME_MAX]; // bin/DSO name |
Anestis Bechtsoudis | 56e360f | 2016-01-11 14:29:17 +0200 | [diff] [blame] | 141 | uint64_t bbCnt; |
| 142 | uint64_t newBBCnt; |
Anestis Bechtsoudis | a16f70f | 2016-01-03 13:03:21 +0200 | [diff] [blame] | 143 | } memMap_t; |
| 144 | |
| 145 | /* Trie node data struct */ |
| 146 | typedef struct __attribute__ ((packed)) { |
Anestis Bechtsoudis | a16f70f | 2016-01-03 13:03:21 +0200 | [diff] [blame] | 147 | bitmap_t *pBM; |
| 148 | } trieData_t; |
| 149 | |
| 150 | /* Trie node struct */ |
Jagger | 7855f6b | 2016-08-31 22:21:33 +0200 | [diff] [blame] | 151 | typedef struct node { |
Anestis Bechtsoudis | a16f70f | 2016-01-03 13:03:21 +0200 | [diff] [blame] | 152 | char key; |
| 153 | trieData_t data; |
| 154 | struct node *next; |
| 155 | struct node *prev; |
| 156 | struct node *children; |
| 157 | struct node *parent; |
| 158 | } node_t; |
Anestis Bechtsoudis | b78cf60 | 2016-01-07 13:10:50 +0200 | [diff] [blame] | 159 | |
Anestis Bechtsoudis | a16f70f | 2016-01-03 13:03:21 +0200 | [diff] [blame] | 160 | /* EOF Sanitizer coverage specific data structures */ |
| 161 | |
| 162 | typedef struct { |
Anestis Bechtsoudis | 61b5ab1 | 2016-01-08 16:07:02 +0200 | [diff] [blame] | 163 | char *asanOpts; |
| 164 | char *msanOpts; |
| 165 | char *ubsanOpts; |
| 166 | } sanOpts_t; |
| 167 | |
Robert Swiecki | 6c9f682 | 2016-03-14 16:12:27 +0100 | [diff] [blame] | 168 | typedef enum { |
| 169 | _HF_STATE_UNSET = 0, |
| 170 | _HF_STATE_STATIC = 1, |
| 171 | _HF_STATE_DYNAMIC_PRE = 2, |
| 172 | _HF_STATE_DYNAMIC_MAIN = 3, |
| 173 | } fuzzState_t; |
| 174 | |
Robert Swiecki | 3bfc33c | 2016-03-14 18:12:41 +0100 | [diff] [blame] | 175 | struct dynfile_t { |
| 176 | uint8_t *data; |
| 177 | size_t size; |
Robert Swiecki | 7084e65 | 2016-03-14 19:47:00 +0100 | [diff] [blame] | 178 | TAILQ_ENTRY(dynfile_t) pointers; |
Robert Swiecki | 3bfc33c | 2016-03-14 18:12:41 +0100 | [diff] [blame] | 179 | }; |
| 180 | |
Robert Swiecki | 531438a | 2016-09-13 19:05:11 +0200 | [diff] [blame] | 181 | struct strings_t { |
| 182 | char *s; |
Jagger | c64c9eb | 2016-09-22 04:04:34 +0200 | [diff] [blame] | 183 | size_t len; |
Robert Swiecki | 531438a | 2016-09-13 19:05:11 +0200 | [diff] [blame] | 184 | TAILQ_ENTRY(strings_t) pointers; |
| 185 | }; |
| 186 | |
Robert Swiecki | e8f8e8d | 2016-10-03 23:51:32 +0200 | [diff] [blame] | 187 | struct paths_t { |
| 188 | char path[PATH_MAX]; |
| 189 | TAILQ_ENTRY(paths_t) pointers; |
| 190 | }; |
| 191 | |
Jagger | fa3544a | 2016-08-30 02:55:55 +0200 | [diff] [blame] | 192 | /* Maximum number of active fuzzing threads */ |
Robert Swiecki | 71b7372 | 2016-09-05 15:18:25 +0200 | [diff] [blame] | 193 | #define _HF_THREAD_MAX 1024U |
Anestis Bechtsoudis | 61b5ab1 | 2016-01-08 16:07:02 +0200 | [diff] [blame] | 194 | typedef struct { |
Robert Swiecki | 7c2c90c | 2016-10-04 02:47:38 +0200 | [diff] [blame] | 195 | bool pcGuardMap[_HF_PC_GUARD_MAX]; |
Jagger | 34789a7 | 2016-09-08 00:36:09 +0200 | [diff] [blame] | 196 | uint8_t bbMapPc[_HF_PERF_BITMAP_SIZE_16M]; |
| 197 | uint8_t bbMapCmp[_HF_PERF_BITMAP_SIZE_16M]; |
| 198 | uint64_t pidFeedbackPc[_HF_THREAD_MAX]; |
| 199 | uint64_t pidFeedbackCmp[_HF_THREAD_MAX]; |
Robert Swiecki | 4f4e829 | 2016-08-23 17:46:32 +0200 | [diff] [blame] | 200 | } feedback_t; |
Jagger | b7fa3ee | 2016-08-21 19:46:26 +0200 | [diff] [blame] | 201 | |
| 202 | typedef struct { |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 203 | char **cmdline; |
Robert Swiecki | f2d9c3a | 2016-11-03 02:13:54 +0100 | [diff] [blame] | 204 | char cmdline_txt[61]; |
Jagger | 1b2d482 | 2016-09-25 16:19:45 +0200 | [diff] [blame] | 205 | char *inputDir; |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 206 | bool nullifyStdio; |
| 207 | bool fuzzStdin; |
| 208 | bool saveUnique; |
Jagger | 0764ad7 | 2015-09-06 01:11:08 +0200 | [diff] [blame] | 209 | bool useScreen; |
Anestis Bechtsoudis | 5c86ebc | 2015-09-27 18:06:43 +0300 | [diff] [blame] | 210 | bool useVerifier; |
Robert Swiecki | 6c9f682 | 2016-03-14 16:12:27 +0100 | [diff] [blame] | 211 | time_t timeStart; |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 212 | char *fileExtn; |
Anestis Bechtsoudis | d968053 | 2015-09-06 17:37:05 +0300 | [diff] [blame] | 213 | char *workDir; |
Jagger | 1b2d482 | 2016-09-25 16:19:45 +0200 | [diff] [blame] | 214 | char *covDir; |
Robert Swiecki | a96d78d | 2016-03-14 16:50:50 +0100 | [diff] [blame] | 215 | double origFlipRate; |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 216 | char *externalCommand; |
Robert Swiecki | ee266ac | 2016-10-03 02:25:59 +0200 | [diff] [blame] | 217 | char *postExternalCommand; |
Anestis Bechtsoudis | d59af69 | 2015-09-21 15:15:05 +0300 | [diff] [blame] | 218 | const char *blacklistFile; |
| 219 | uint64_t *blacklist; |
| 220 | size_t blacklistCnt; |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 221 | long tmOut; |
Jagger | ea39a8f | 2015-09-05 00:57:22 +0200 | [diff] [blame] | 222 | size_t mutationsMax; |
Jagger | ea39a8f | 2015-09-05 00:57:22 +0200 | [diff] [blame] | 223 | size_t threadsMax; |
| 224 | size_t threadsFinished; |
robert.swiecki@gmail.com | 4da86bf | 2015-02-22 14:24:58 +0000 | [diff] [blame] | 225 | size_t maxFileSz; |
robert.swiecki@gmail.com | e7190b9 | 2015-02-14 23:05:42 +0000 | [diff] [blame] | 226 | char *reportFile; |
Robert Swiecki | c578d64 | 2015-09-08 16:13:36 +0200 | [diff] [blame] | 227 | uint64_t asLimit; |
Robert Swiecki | 3a57226 | 2016-10-04 01:48:34 +0200 | [diff] [blame] | 228 | TAILQ_HEAD(, paths_t) fileq; |
Anestis Bechtsoudis | 46ea10e | 2015-11-07 18:16:25 +0200 | [diff] [blame] | 229 | size_t fileCnt; |
Robert Swiecki | 05354ca | 2016-03-15 19:10:23 +0100 | [diff] [blame] | 230 | size_t lastFileIndex; |
| 231 | size_t doneFileIndex; |
Jagger | 80041fe | 2016-03-10 21:32:35 +0100 | [diff] [blame] | 232 | bool clearEnv; |
robert.swiecki@gmail.com | 15eca6f | 2015-03-04 03:31:36 +0000 | [diff] [blame] | 233 | char *envs[128]; |
Robert Swiecki | 0f937af | 2016-03-30 18:19:16 +0200 | [diff] [blame] | 234 | bool persistent; |
Robert Swiecki | e84b645 | 2016-12-12 12:42:04 +0100 | [diff] [blame] | 235 | bool tmout_vtalrm; |
Anestis Bechtsoudis | e5f09f8 | 2016-12-27 16:06:05 +0200 | [diff] [blame] | 236 | bool enableSanitizers; |
| 237 | bool monitorSIGABRT; |
robert.swiecki@gmail.com | 41d8e05 | 2015-02-19 01:10:41 +0000 | [diff] [blame] | 238 | |
Robert Swiecki | 531438a | 2016-09-13 19:05:11 +0200 | [diff] [blame] | 239 | const char *dictionaryFile; |
Robert Swiecki | 3a57226 | 2016-10-04 01:48:34 +0200 | [diff] [blame] | 240 | TAILQ_HEAD(, strings_t) dictq; |
Robert Swiecki | 531438a | 2016-09-13 19:05:11 +0200 | [diff] [blame] | 241 | size_t dictionaryCnt; |
| 242 | |
Robert Swiecki | 6c9f682 | 2016-03-14 16:12:27 +0100 | [diff] [blame] | 243 | fuzzState_t state; |
Jagger | b7fa3ee | 2016-08-21 19:46:26 +0200 | [diff] [blame] | 244 | feedback_t *feedback; |
Robert Swiecki | bc7532e | 2016-08-20 00:34:17 +0200 | [diff] [blame] | 245 | int bbFd; |
Robert Swiecki | 3bfc33c | 2016-03-14 18:12:41 +0100 | [diff] [blame] | 246 | size_t dynfileqCnt; |
Robert Swiecki | e586c1f | 2016-03-14 18:46:03 +0100 | [diff] [blame] | 247 | pthread_mutex_t dynfileq_mutex; |
Robert Swiecki | 3a57226 | 2016-10-04 01:48:34 +0200 | [diff] [blame] | 248 | TAILQ_HEAD(, dynfile_t) dynfileq; |
Robert Swiecki | 6c9f682 | 2016-03-14 16:12:27 +0100 | [diff] [blame] | 249 | |
Jagger | 0764ad7 | 2015-09-06 01:11:08 +0200 | [diff] [blame] | 250 | size_t mutationsCnt; |
| 251 | size_t crashesCnt; |
Anestis Bechtsoudis | d7e8ed2 | 2015-09-10 18:29:34 +0300 | [diff] [blame] | 252 | size_t uniqueCrashesCnt; |
Anestis Bechtsoudis | 79b799e | 2015-11-01 00:02:25 +0200 | [diff] [blame] | 253 | size_t verifiedCrashesCnt; |
Anestis Bechtsoudis | d59af69 | 2015-09-21 15:15:05 +0300 | [diff] [blame] | 254 | size_t blCrashesCnt; |
Jagger | 4b5281e | 2015-09-06 02:35:37 +0200 | [diff] [blame] | 255 | size_t timeoutedCnt; |
Jagger | 0764ad7 | 2015-09-06 01:11:08 +0200 | [diff] [blame] | 256 | |
robert.swiecki@gmail.com | cac22fd | 2015-02-19 14:03:28 +0000 | [diff] [blame] | 257 | dynFileMethod_t dynFileMethod; |
Anestis Bechtsoudis | be0ac7b | 2015-12-26 15:38:47 +0200 | [diff] [blame] | 258 | sancovcnt_t sanCovCnts; |
Anestis Bechtsoudis | a16f70f | 2016-01-03 13:03:21 +0200 | [diff] [blame] | 259 | pthread_mutex_t sanCov_mutex; |
Anestis Bechtsoudis | 61b5ab1 | 2016-01-08 16:07:02 +0200 | [diff] [blame] | 260 | sanOpts_t sanOpts; |
Robert Swiecki | 6c9f682 | 2016-03-14 16:12:27 +0100 | [diff] [blame] | 261 | size_t dynFileIterExpire; |
| 262 | bool useSanCov; |
| 263 | node_t *covMetadata; |
Jagger | 247c3b4 | 2016-03-21 23:24:05 +0100 | [diff] [blame] | 264 | bool msanReportUMRS; |
Robert Swiecki | 6c9f682 | 2016-03-14 16:12:27 +0100 | [diff] [blame] | 265 | |
Haris Andrianakis | c9a7133 | 2016-05-09 21:56:30 -0700 | [diff] [blame] | 266 | pthread_mutex_t report_mutex; |
| 267 | |
Robert Swiecki | 6c9f682 | 2016-03-14 16:12:27 +0100 | [diff] [blame] | 268 | /* For the Linux code */ |
Jagger | 247c3b4 | 2016-03-21 23:24:05 +0100 | [diff] [blame] | 269 | struct { |
| 270 | hwcnt_t hwCnts; |
| 271 | uint64_t dynamicCutOffAddr; |
| 272 | bool disableRandomization; |
| 273 | void *ignoreAddr; |
| 274 | size_t numMajorFrames; |
| 275 | pid_t pid; |
| 276 | const char *pidFile; |
| 277 | char *pidCmd; |
Anestis Bechtsoudis | ba68b38 | 2016-10-29 20:44:15 +0300 | [diff] [blame] | 278 | const char *symsBlFile; |
| 279 | char **symsBl; |
| 280 | size_t symsBlCnt; |
| 281 | const char *symsWlFile; |
| 282 | char **symsWl; |
| 283 | size_t symsWlCnt; |
Robert Swiecki | 846ccd7 | 2017-01-12 17:52:23 +0100 | [diff] [blame] | 284 | uintptr_t cloneFlags; |
Jagger | 247c3b4 | 2016-03-21 23:24:05 +0100 | [diff] [blame] | 285 | } linux; |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 286 | } honggfuzz_t; |
| 287 | |
Jagger | e6be75c | 2016-03-17 03:18:04 +0100 | [diff] [blame] | 288 | typedef struct { |
robert.swiecki@gmail.com | 882900b | 2015-02-11 13:56:22 +0000 | [diff] [blame] | 289 | pid_t pid; |
Robert Swiecki | decf14b | 2016-03-31 15:09:28 +0200 | [diff] [blame] | 290 | pid_t persistentPid; |
robert.swiecki@gmail.com | 3213a11 | 2015-03-12 01:42:02 +0000 | [diff] [blame] | 291 | int64_t timeStartedMillis; |
Robert Swiecki | decf14b | 2016-03-31 15:09:28 +0200 | [diff] [blame] | 292 | const char *origFileName; |
robert.swiecki@gmail.com | 882900b | 2015-02-11 13:56:22 +0000 | [diff] [blame] | 293 | char fileName[PATH_MAX]; |
Anestis Bechtsoudis | 5c86ebc | 2015-09-27 18:06:43 +0300 | [diff] [blame] | 294 | char crashFileName[PATH_MAX]; |
robert.swiecki@gmail.com | 882900b | 2015-02-11 13:56:22 +0000 | [diff] [blame] | 295 | uint64_t pc; |
| 296 | uint64_t backtrace; |
| 297 | uint64_t access; |
| 298 | int exception; |
Anestis Bechtsoudis | c06f8b3 | 2015-12-26 14:48:05 +0200 | [diff] [blame] | 299 | char report[_HF_REPORT_SIZE]; |
Anestis Bechtsoudis | 6b9e83d | 2015-10-02 11:10:50 -0700 | [diff] [blame] | 300 | bool mainWorker; |
Robert Swiecki | a96d78d | 2016-03-14 16:50:50 +0100 | [diff] [blame] | 301 | float flipRate; |
Robert Swiecki | a96d78d | 2016-03-14 16:50:50 +0100 | [diff] [blame] | 302 | uint8_t *dynamicFile; |
| 303 | size_t dynamicFileSz; |
Jagger | fa3544a | 2016-08-30 02:55:55 +0200 | [diff] [blame] | 304 | uint32_t fuzzNo; |
Jagger | 93253f7 | 2016-09-01 22:40:12 +0200 | [diff] [blame] | 305 | int persistentSock; |
Robert Swiecki | 013bc9c | 2016-12-12 17:31:06 +0100 | [diff] [blame] | 306 | bool tmOutSignaled; |
Jagger | 2c1a691 | 2016-09-04 03:37:06 +0200 | [diff] [blame] | 307 | #if !defined(_HF_ARCH_DARWIN) |
Jagger | f159a15 | 2016-09-02 02:22:09 +0200 | [diff] [blame] | 308 | timer_t timerId; |
Jagger | 2c1a691 | 2016-09-04 03:37:06 +0200 | [diff] [blame] | 309 | #endif // !defined(_HF_ARCH_DARWIN) |
robert.swiecki@gmail.com | d4dd4df | 2015-02-18 00:50:12 +0000 | [diff] [blame] | 310 | |
Robert Swiecki | decf14b | 2016-03-31 15:09:28 +0200 | [diff] [blame] | 311 | sancovcnt_t sanCovCnts; |
| 312 | |
Jagger | 2381ef4 | 2016-03-20 23:32:05 +0100 | [diff] [blame] | 313 | struct { |
| 314 | /* For Linux code */ |
Jagger | 2381ef4 | 2016-03-20 23:32:05 +0100 | [diff] [blame] | 315 | uint8_t *perfMmapBuf; |
| 316 | uint8_t *perfMmapAux; |
Robert Swiecki | decf14b | 2016-03-31 15:09:28 +0200 | [diff] [blame] | 317 | hwcnt_t hwCnts; |
Robert Swiecki | 12800cd | 2016-03-31 15:38:10 +0200 | [diff] [blame] | 318 | pid_t attachedPid; |
Jagger | 98f0a0a | 2016-09-02 01:00:52 +0200 | [diff] [blame] | 319 | int cpuInstrFd; |
| 320 | int cpuBranchFd; |
| 321 | int cpuIptBtsFd; |
Jagger | 2381ef4 | 2016-03-20 23:32:05 +0100 | [diff] [blame] | 322 | } linux; |
robert.swiecki@gmail.com | 882900b | 2015-02-11 13:56:22 +0000 | [diff] [blame] | 323 | } fuzzer_t; |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 324 | |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 325 | #endif |