[PATCH] D63334: [libFuzzer] Disable len_control by default if LLVMFuzzerCustomMutator is used.

Max Moroz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 07:17:50 PDT 2019


Dor1s created this revision.
Dor1s added reviewers: kcc, vitalybuka, metzman.
Herald added subscribers: Sanitizers, delcypher.
Herald added projects: LLVM, Sanitizers.

Some custom mutators may not peform well when size restriction is
enforced by len_control. Because of that, it's safer to disable len_control
by default in such cases, but still allow users to enable it manually.
Bug example: https://bugs.chromium.org/p/chromium/issues/detail?id=919530.

Tested manually with LPM-based and regular fuzz targets.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D63334

Files:
  lib/fuzzer/FuzzerDriver.cpp
  lib/fuzzer/FuzzerFlags.def


Index: lib/fuzzer/FuzzerFlags.def
===================================================================
--- lib/fuzzer/FuzzerFlags.def
+++ lib/fuzzer/FuzzerFlags.def
@@ -19,7 +19,7 @@
 FUZZER_FLAG_INT(len_control, 100, "Try generating small inputs first, "
   "then try larger inputs over time.  Specifies the rate at which the length "
   "limit is increased (smaller == faster).  If 0, immediately try inputs with "
-  "size up to max_len.")
+  "size up to max_len. Default value is 0, if LLVMFuzzerCustomMutator is used.")
 FUZZER_FLAG_STRING(seed_inputs, "A comma-separated list of input files "
   "to use as an additional seed corpus. Alternatively, an \"@\" followed by "
   "the name of a file containing the comma-seperated list.")
Index: lib/fuzzer/FuzzerDriver.cpp
===================================================================
--- lib/fuzzer/FuzzerDriver.cpp
+++ lib/fuzzer/FuzzerDriver.cpp
@@ -182,7 +182,8 @@
 }
 
 // We don't use any library to minimize dependencies.
-static void ParseFlags(const Vector<std::string> &Args) {
+static void ParseFlags(const Vector<std::string> &Args,
+                       const ExternalFunctions *EF) {
   for (size_t F = 0; F < kNumFlags; F++) {
     if (FlagDescriptions[F].IntFlag)
       *FlagDescriptions[F].IntFlag = FlagDescriptions[F].Default;
@@ -192,6 +193,11 @@
     if (FlagDescriptions[F].StrFlag)
       *FlagDescriptions[F].StrFlag = nullptr;
   }
+
+  // Disable len_control by default, if LLVMFuzzerCustomMutator is used.
+  if (EF->LLVMFuzzerCustomMutator)
+    Flags.len_control = 0;
+
   Inputs = new Vector<std::string>;
   for (size_t A = 1; A < Args.size(); A++) {
     if (ParseOneFlag(Args[A].c_str())) {
@@ -616,7 +622,7 @@
     Printf("ERROR: argv[0] has been modified in LLVMFuzzerInitialize\n");
     exit(1);
   }
-  ParseFlags(Args);
+  ParseFlags(Args, EF);
   if (Flags.help) {
     PrintHelp();
     return 0;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63334.204765.patch
Type: text/x-patch
Size: 1898 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190614/92eae25f/attachment.bin>


More information about the llvm-commits mailing list