13cab2bb3Spatrick//===- FuzzerFlags.def - Run-time flags -------------------------*- C++ -* ===// 23cab2bb3Spatrick// 33cab2bb3Spatrick// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 43cab2bb3Spatrick// See https://llvm.org/LICENSE.txt for license information. 53cab2bb3Spatrick// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 63cab2bb3Spatrick// 73cab2bb3Spatrick//===----------------------------------------------------------------------===// 83cab2bb3Spatrick// Flags. FUZZER_FLAG_INT/FUZZER_FLAG_STRING macros should be defined at the 93cab2bb3Spatrick// point of inclusion. We are not using any flag parsing library for better 103cab2bb3Spatrick// portability and independence. 113cab2bb3Spatrick//===----------------------------------------------------------------------===// 123cab2bb3SpatrickFUZZER_FLAG_INT(verbosity, 1, "Verbosity level.") 133cab2bb3SpatrickFUZZER_FLAG_UNSIGNED(seed, 0, "Random seed. If 0, seed is generated.") 143cab2bb3SpatrickFUZZER_FLAG_INT(runs, -1, 153cab2bb3Spatrick "Number of individual test runs (-1 for infinite runs).") 163cab2bb3SpatrickFUZZER_FLAG_INT(max_len, 0, "Maximum length of the test input. " 173cab2bb3Spatrick "If 0, libFuzzer tries to guess a good value based on the corpus " 183cab2bb3Spatrick "and reports it. ") 193cab2bb3SpatrickFUZZER_FLAG_INT(len_control, 100, "Try generating small inputs first, " 203cab2bb3Spatrick "then try larger inputs over time. Specifies the rate at which the length " 213cab2bb3Spatrick "limit is increased (smaller == faster). If 0, immediately try inputs with " 223cab2bb3Spatrick "size up to max_len. Default value is 0, if LLVMFuzzerCustomMutator is used.") 233cab2bb3SpatrickFUZZER_FLAG_STRING(seed_inputs, "A comma-separated list of input files " 243cab2bb3Spatrick "to use as an additional seed corpus. Alternatively, an \"@\" followed by " 251f9cb04fSpatrick "the name of a file containing the comma-separated list.") 26d89ec533SpatrickFUZZER_FLAG_INT(keep_seed, 0, "If 1, keep seed inputs in the corpus even if " 27d89ec533Spatrick "they do not produce new coverage. When used with |reduce_inputs==1|, the " 28d89ec533Spatrick "seed inputs will never be reduced. This option can be useful when seeds are" 29d89ec533Spatrick "not properly formed for the fuzz target but still have useful snippets.") 303cab2bb3SpatrickFUZZER_FLAG_INT(cross_over, 1, "If 1, cross over inputs.") 31d89ec533SpatrickFUZZER_FLAG_INT(cross_over_uniform_dist, 0, "Experimental. If 1, use a " 32d89ec533Spatrick "uniform probability distribution when choosing inputs to cross over with. " 33d89ec533Spatrick "Some of the inputs in the corpus may never get chosen for mutation " 34d89ec533Spatrick "depending on the input mutation scheduling policy. With this flag, all " 35d89ec533Spatrick "inputs, regardless of the input mutation scheduling policy, can be chosen " 36d89ec533Spatrick "as an input to cross over with. This can be particularly useful with " 37d89ec533Spatrick "|keep_seed==1|; all the initial seed inputs, even though they do not " 38d89ec533Spatrick "increase coverage because they are not properly formed, will still be " 39d89ec533Spatrick "chosen as an input to cross over with.") 40d89ec533Spatrick 413cab2bb3SpatrickFUZZER_FLAG_INT(mutate_depth, 5, 423cab2bb3Spatrick "Apply this number of consecutive mutations to each input.") 433cab2bb3SpatrickFUZZER_FLAG_INT(reduce_depth, 0, "Experimental/internal. " 443cab2bb3Spatrick "Reduce depth if mutations lose unique features") 453cab2bb3SpatrickFUZZER_FLAG_INT(shuffle, 1, "Shuffle inputs at startup") 463cab2bb3SpatrickFUZZER_FLAG_INT(prefer_small, 1, 473cab2bb3Spatrick "If 1, always prefer smaller inputs during the corpus shuffle.") 483cab2bb3SpatrickFUZZER_FLAG_INT( 493cab2bb3Spatrick timeout, 1200, 503cab2bb3Spatrick "Timeout in seconds (if positive). " 513cab2bb3Spatrick "If one unit runs more than this number of seconds the process will abort.") 523cab2bb3SpatrickFUZZER_FLAG_INT(error_exitcode, 77, "When libFuzzer itself reports a bug " 533cab2bb3Spatrick "this exit code will be used.") 543cab2bb3SpatrickFUZZER_FLAG_INT(timeout_exitcode, 70, "When libFuzzer reports a timeout " 553cab2bb3Spatrick "this exit code will be used.") 563cab2bb3SpatrickFUZZER_FLAG_INT(max_total_time, 0, "If positive, indicates the maximal total " 573cab2bb3Spatrick "time in seconds to run the fuzzer.") 583cab2bb3SpatrickFUZZER_FLAG_INT(help, 0, "Print help.") 593cab2bb3SpatrickFUZZER_FLAG_INT(fork, 0, "Experimental mode where fuzzing happens " 603cab2bb3Spatrick "in a subprocess") 61*810390e3SrobertFUZZER_FLAG_INT(fork_corpus_groups, 0, "For fork mode, enable the corpus-group " 62*810390e3Srobert "strategy, The main corpus will be grouped according to size, " 63*810390e3Srobert "and each sub-process will randomly select seeds from different " 64*810390e3Srobert "groups as the sub-corpus.") 653cab2bb3SpatrickFUZZER_FLAG_INT(ignore_timeouts, 1, "Ignore timeouts in fork mode") 663cab2bb3SpatrickFUZZER_FLAG_INT(ignore_ooms, 1, "Ignore OOMs in fork mode") 673cab2bb3SpatrickFUZZER_FLAG_INT(ignore_crashes, 0, "Ignore crashes in fork mode") 683cab2bb3SpatrickFUZZER_FLAG_INT(merge, 0, "If 1, the 2-nd, 3-rd, etc corpora will be " 693cab2bb3Spatrick "merged into the 1-st corpus. Only interesting units will be taken. " 703cab2bb3Spatrick "This flag can be used to minimize a corpus.") 71*810390e3SrobertFUZZER_FLAG_INT(set_cover_merge, 0, "If 1, the 2-nd, 3-rd, etc corpora will be " 72*810390e3Srobert "merged into the 1-st corpus. Same as the 'merge' flag, but uses the " 73*810390e3Srobert "standard greedy algorithm for the set cover problem to " 74*810390e3Srobert "compute an approximation of the minimum set of testcases that " 75*810390e3Srobert "provide the same coverage as the initial corpora") 763cab2bb3SpatrickFUZZER_FLAG_STRING(stop_file, "Stop fuzzing ASAP if this file exists") 773cab2bb3SpatrickFUZZER_FLAG_STRING(merge_inner, "internal flag") 783cab2bb3SpatrickFUZZER_FLAG_STRING(merge_control_file, 793cab2bb3Spatrick "Specify a control file used for the merge process. " 803cab2bb3Spatrick "If a merge process gets killed it tries to leave this file " 813cab2bb3Spatrick "in a state suitable for resuming the merge. " 823cab2bb3Spatrick "By default a temporary file will be used." 833cab2bb3Spatrick "The same file can be used for multistep merge process.") 843cab2bb3SpatrickFUZZER_FLAG_INT(minimize_crash, 0, "If 1, minimizes the provided" 853cab2bb3Spatrick " crash input. Use with -runs=N or -max_total_time=N to limit " 863cab2bb3Spatrick "the number attempts." 873cab2bb3Spatrick " Use with -exact_artifact_path to specify the output." 883cab2bb3Spatrick " Combine with ASAN_OPTIONS=dedup_token_length=3 (or similar) to ensure that" 893cab2bb3Spatrick " the minimized input triggers the same crash." 903cab2bb3Spatrick ) 913cab2bb3SpatrickFUZZER_FLAG_INT(cleanse_crash, 0, "If 1, tries to cleanse the provided" 923cab2bb3Spatrick " crash input to make it contain fewer original bytes." 933cab2bb3Spatrick " Use with -exact_artifact_path to specify the output." 943cab2bb3Spatrick ) 953cab2bb3SpatrickFUZZER_FLAG_INT(minimize_crash_internal_step, 0, "internal flag") 963cab2bb3SpatrickFUZZER_FLAG_STRING(features_dir, "internal flag. Used to dump feature sets on disk." 973cab2bb3Spatrick "Every time a new input is added to the corpus, a corresponding file in the features_dir" 983cab2bb3Spatrick " is created containing the unique features of that input." 993cab2bb3Spatrick " Features are stored in binary format.") 100d89ec533SpatrickFUZZER_FLAG_STRING(mutation_graph_file, "Saves a graph (in DOT format) to" 101d89ec533Spatrick " mutation_graph_file. The graph contains a vertex for each input that has" 102d89ec533Spatrick " unique coverage; directed edges are provided between parents and children" 103d89ec533Spatrick " where the child has unique coverage, and are recorded with the type of" 104d89ec533Spatrick " mutation that caused the child.") 1053cab2bb3SpatrickFUZZER_FLAG_INT(use_counters, 1, "Use coverage counters") 1063cab2bb3SpatrickFUZZER_FLAG_INT(use_memmem, 1, 1073cab2bb3Spatrick "Use hints from intercepting memmem, strstr, etc") 1083cab2bb3SpatrickFUZZER_FLAG_INT(use_value_profile, 0, 1093cab2bb3Spatrick "Experimental. Use value profile to guide fuzzing.") 1103cab2bb3SpatrickFUZZER_FLAG_INT(use_cmp, 1, "Use CMP traces to guide mutations") 1113cab2bb3SpatrickFUZZER_FLAG_INT(shrink, 0, "Experimental. Try to shrink corpus inputs.") 1123cab2bb3SpatrickFUZZER_FLAG_INT(reduce_inputs, 1, 1133cab2bb3Spatrick "Try to reduce the size of inputs while preserving their full feature sets") 1143cab2bb3SpatrickFUZZER_FLAG_UNSIGNED(jobs, 0, "Number of jobs to run. If jobs >= 1 we spawn" 1153cab2bb3Spatrick " this number of jobs in separate worker processes" 1163cab2bb3Spatrick " with stdout/stderr redirected to fuzz-JOB.log.") 1173cab2bb3SpatrickFUZZER_FLAG_UNSIGNED(workers, 0, 1183cab2bb3Spatrick "Number of simultaneous worker processes to run the jobs." 1193cab2bb3Spatrick " If zero, \"min(jobs,NumberOfCpuCores()/2)\" is used.") 1203cab2bb3SpatrickFUZZER_FLAG_INT(reload, 1, 1213cab2bb3Spatrick "Reload the main corpus every <N> seconds to get new units" 1223cab2bb3Spatrick " discovered by other processes. If 0, disabled") 1233cab2bb3SpatrickFUZZER_FLAG_INT(report_slow_units, 10, 1243cab2bb3Spatrick "Report slowest units if they run for more than this number of seconds.") 1253cab2bb3SpatrickFUZZER_FLAG_INT(only_ascii, 0, 1263cab2bb3Spatrick "If 1, generate only ASCII (isprint+isspace) inputs.") 1273cab2bb3SpatrickFUZZER_FLAG_STRING(dict, "Experimental. Use the dictionary file.") 1283cab2bb3SpatrickFUZZER_FLAG_STRING(artifact_prefix, "Write fuzzing artifacts (crash, " 1293cab2bb3Spatrick "timeout, or slow inputs) as " 1303cab2bb3Spatrick "$(artifact_prefix)file") 1313cab2bb3SpatrickFUZZER_FLAG_STRING(exact_artifact_path, 1323cab2bb3Spatrick "Write the single artifact on failure (crash, timeout) " 1333cab2bb3Spatrick "as $(exact_artifact_path). This overrides -artifact_prefix " 1343cab2bb3Spatrick "and will not use checksum in the file name. Do not " 1353cab2bb3Spatrick "use the same path for several parallel processes.") 1363cab2bb3SpatrickFUZZER_FLAG_INT(print_pcs, 0, "If 1, print out newly covered PCs.") 1373cab2bb3SpatrickFUZZER_FLAG_INT(print_funcs, 2, "If >=1, print out at most this number of " 1383cab2bb3Spatrick "newly covered functions.") 1393cab2bb3SpatrickFUZZER_FLAG_INT(print_final_stats, 0, "If 1, print statistics at exit.") 1403cab2bb3SpatrickFUZZER_FLAG_INT(print_corpus_stats, 0, 1413cab2bb3Spatrick "If 1, print statistics on corpus elements at exit.") 1423cab2bb3SpatrickFUZZER_FLAG_INT(print_coverage, 0, "If 1, print coverage information as text" 1433cab2bb3Spatrick " at exit.") 144d89ec533SpatrickFUZZER_FLAG_INT(print_full_coverage, 0, "If 1, print full coverage information " 145d89ec533Spatrick "(all branches) as text at exit.") 1463cab2bb3SpatrickFUZZER_FLAG_INT(dump_coverage, 0, "Deprecated.") 1473cab2bb3SpatrickFUZZER_FLAG_INT(handle_segv, 1, "If 1, try to intercept SIGSEGV.") 1483cab2bb3SpatrickFUZZER_FLAG_INT(handle_bus, 1, "If 1, try to intercept SIGBUS.") 1493cab2bb3SpatrickFUZZER_FLAG_INT(handle_abrt, 1, "If 1, try to intercept SIGABRT.") 1503cab2bb3SpatrickFUZZER_FLAG_INT(handle_ill, 1, "If 1, try to intercept SIGILL.") 1513cab2bb3SpatrickFUZZER_FLAG_INT(handle_fpe, 1, "If 1, try to intercept SIGFPE.") 1523cab2bb3SpatrickFUZZER_FLAG_INT(handle_int, 1, "If 1, try to intercept SIGINT.") 1533cab2bb3SpatrickFUZZER_FLAG_INT(handle_term, 1, "If 1, try to intercept SIGTERM.") 1543cab2bb3SpatrickFUZZER_FLAG_INT(handle_xfsz, 1, "If 1, try to intercept SIGXFSZ.") 1553cab2bb3SpatrickFUZZER_FLAG_INT(handle_usr1, 1, "If 1, try to intercept SIGUSR1.") 1563cab2bb3SpatrickFUZZER_FLAG_INT(handle_usr2, 1, "If 1, try to intercept SIGUSR2.") 157d89ec533SpatrickFUZZER_FLAG_INT(handle_winexcept, 1, "If 1, try to intercept uncaught Windows " 158d89ec533Spatrick "Visual C++ Exceptions.") 1593cab2bb3SpatrickFUZZER_FLAG_INT(close_fd_mask, 0, "If 1, close stdout at startup; " 1603cab2bb3Spatrick "if 2, close stderr; if 3, close both. " 1613cab2bb3Spatrick "Be careful, this will also close e.g. stderr of asan.") 1623cab2bb3SpatrickFUZZER_FLAG_INT(detect_leaks, 1, "If 1, and if LeakSanitizer is enabled " 1633cab2bb3Spatrick "try to detect memory leaks during fuzzing (i.e. not only at shut down).") 1643cab2bb3SpatrickFUZZER_FLAG_INT(purge_allocator_interval, 1, "Purge allocator caches and " 1653cab2bb3Spatrick "quarantines every <N> seconds. When rss_limit_mb is specified (>0), " 1663cab2bb3Spatrick "purging starts when RSS exceeds 50% of rss_limit_mb. Pass " 1673cab2bb3Spatrick "purge_allocator_interval=-1 to disable this functionality.") 1683cab2bb3SpatrickFUZZER_FLAG_INT(trace_malloc, 0, "If >= 1 will print all mallocs/frees. " 1693cab2bb3Spatrick "If >= 2 will also print stack traces.") 1703cab2bb3SpatrickFUZZER_FLAG_INT(rss_limit_mb, 2048, "If non-zero, the fuzzer will exit upon" 1713cab2bb3Spatrick "reaching this limit of RSS memory usage.") 1723cab2bb3SpatrickFUZZER_FLAG_INT(malloc_limit_mb, 0, "If non-zero, the fuzzer will exit " 1733cab2bb3Spatrick "if the target tries to allocate this number of Mb with one malloc call. " 1743cab2bb3Spatrick "If zero (default) same limit as rss_limit_mb is applied.") 1753cab2bb3SpatrickFUZZER_FLAG_STRING(exit_on_src_pos, "Exit if a newly found PC originates" 1763cab2bb3Spatrick " from the given source location. Example: -exit_on_src_pos=foo.cc:123. " 1773cab2bb3Spatrick "Used primarily for testing libFuzzer itself.") 1783cab2bb3SpatrickFUZZER_FLAG_STRING(exit_on_item, "Exit if an item with a given sha1 sum" 1793cab2bb3Spatrick " was added to the corpus. " 1803cab2bb3Spatrick "Used primarily for testing libFuzzer itself.") 1813cab2bb3SpatrickFUZZER_FLAG_INT(ignore_remaining_args, 0, "If 1, ignore all arguments passed " 1823cab2bb3Spatrick "after this one. Useful for fuzzers that need to do their own " 1833cab2bb3Spatrick "argument parsing.") 1843cab2bb3SpatrickFUZZER_FLAG_STRING(focus_function, "Experimental. " 1853cab2bb3Spatrick "Fuzzing will focus on inputs that trigger calls to this function. " 1863cab2bb3Spatrick "If -focus_function=auto and -data_flow_trace is used, libFuzzer " 187d89ec533Spatrick "will choose the focus functions automatically. Disables -entropic when " 188d89ec533Spatrick "specified.") 189d89ec533SpatrickFUZZER_FLAG_INT(entropic, 1, "Enables entropic power schedule.") 1901f9cb04fSpatrickFUZZER_FLAG_INT(entropic_feature_frequency_threshold, 0xFF, "Experimental. If " 1911f9cb04fSpatrick "entropic is enabled, all features which are observed less often than " 1921f9cb04fSpatrick "the specified value are considered as rare.") 1931f9cb04fSpatrickFUZZER_FLAG_INT(entropic_number_of_rarest_features, 100, "Experimental. If " 1941f9cb04fSpatrick "entropic is enabled, we keep track of the frequencies only for the " 1951f9cb04fSpatrick "Top-X least abundant features (union features that are considered as " 1961f9cb04fSpatrick "rare).") 197d89ec533SpatrickFUZZER_FLAG_INT(entropic_scale_per_exec_time, 0, "Experimental. If 1, " 198d89ec533Spatrick "the Entropic power schedule gets scaled based on the input execution " 199d89ec533Spatrick "time. Inputs with lower execution time get scheduled more (up to 30x). " 200d89ec533Spatrick "Note that, if 1, fuzzer stops from being deterministic even if a " 201d89ec533Spatrick "non-zero random seed is given.") 2023cab2bb3Spatrick 2033cab2bb3SpatrickFUZZER_FLAG_INT(analyze_dict, 0, "Experimental") 2043cab2bb3SpatrickFUZZER_DEPRECATED_FLAG(use_clang_coverage) 2053cab2bb3SpatrickFUZZER_FLAG_STRING(data_flow_trace, "Experimental: use the data flow trace") 2063cab2bb3SpatrickFUZZER_FLAG_STRING(collect_data_flow, 2073cab2bb3Spatrick "Experimental: collect the data flow trace") 208d89ec533Spatrick 209d89ec533SpatrickFUZZER_FLAG_INT(create_missing_dirs, 0, "Automatically attempt to create " 210d89ec533Spatrick "directories for arguments that would normally expect them to already " 211d89ec533Spatrick "exist (i.e. artifact_prefix, exact_artifact_path, features_dir, corpus)") 212