aboutsummaryrefslogtreecommitdiff
path: root/third_party
AgeCommit message (Collapse)Author
2022-08-10driver: Split libfuzzer_{driver,fuzz_target} into main and libraryFabian Meumertzheim
By using LLVMFuzzerRunDriver, we can remove the LibfuzzerDriver class and replace it by: * a real main function that preprocesses arguments for libFuzzer and starts a JVM; * everything else turned into a proper library with no dependency on our custom JVM class. This will allow us to turn everything except the main function into a JNI shared library, opening up the possibility to launch Jazzer from an already running JVM.
2022-07-25Fix TurbojpegFuzzer native library pathFabian Meumertzheim
The native library path for this example got lost during the migration to rules_jni and is required for the fuzz target to be functional. Also updates rules_foreign_cc and cleans up the attributes passed to the cmake rule. This includes adding -fPIC as a speculative fix for relocation issues reported by the linker.
2022-06-24Fix infinite recursion in ProbeInserter patchFabian Meumertzheim
Speculative fix for the following externally reported issue: ``` INFO: Instrumented com.... java.lang.StackOverflowError at org.jacoco.core.internal.instr.ProbeInserter.visitLocalVariableAnnotation(ProbeInserter.java:126) at org.jacoco.core.internal.instr.ProbeInserter.visitLocalVariableAnnotation(ProbeInserter.java:126) ... ... ... at org.jacoco.core.internal.instr.ProbeInserter.visitLocalVariableAnnotation(ProbeInserter.java:126) INFO: Instrumented com.... ```
2022-05-20Update Bazel to 5.2.0rc1Fabian Meumertzheim
This release contains a number of fixes to coverage collection for multi-language targets. A new ErrorProne check has to be disabled for the JaCoCo build to pass.
2022-04-28Update JaCoCo to 0.8.8Fabian Meumertzheim
2022-04-06Use the official JaCoCo versionNorbert Schneider
Switch from the internal fork to the official JaCoCo version. This looses the call optimizations but removes the burden of maintaining a dedicated fork. Tests using the example fuzzers and JMH don't show huge performance differences. Some are more in favor of the fork, some of the official version.
2022-03-23Shade JaCoCo internally to allow for coverage collection in JazzerFabian Meumertzheim
If we do not shade JaCoCo internally but only when preparing the agent deploy jar, Jazzer tests themselves can't be instrumented with JaCoCo as our patched version is incompatible with the one used by coverage tools.
2022-03-23Simplify agent shading rulesFabian Meumertzheim
2022-03-21Build jacoco cli internallyNorbert Schneider
2022-02-11Get ASM from Maven rather than gitlab.ow2.orgFabian Meumertzheim
The OW2 GitLab hasn't been very reliable in the past and just encountered another outage. Getting the ASM jars from Maven should be more reliable.
2022-02-09Use LLVM's CMake C flags for libfuzzerFabian Meumertzheim
We were using the flags from a standalone build script for libFuzzer, but should instead try to use the same set of flags as an LLVM release would use.
2022-01-28Extract coverage counters descriptor out of patchFabian Meumertzheim
2021-12-07Update toolchain to LLVM 13Fabian Meumertzheim
2021-12-07Update bazel_toolchainFabian Meumertzheim
2021-11-15Suppress javac warnings on JaCoCoFabian Meumertzheim
2021-11-12Extract JavaNoThrowMethods logic into a JaCoCo forkFabian Meumertzheim
The fork of JaCoCo is compatible with the exec files generated by Jazzer's dumpCoverage. This also reduces the size of the patches maintained in this repo.
2021-10-21Remove remaining loads of @rules_javaFabian Meumertzheim
2021-10-19Add basic generic autofuzz and consume functionalityFabian Meumertzheim
2021-10-18Add copts and linkopts for WindowsFabian Meumertzheim
2021-10-17Use rules_jniFabian Meumertzheim
This simplifies the libjvm location logic as well as native library packaging. Incidentally, this fixes the libjpeg_turbo build. In anticipation of Windows support and because it simplifies further improvements to the fuzz target test setup, the wrapper is rewritten in Java.
2021-10-15Do not use @rules_java and @rules_ccFabian Meumertzheim
These repositories are no longer how starlarkified rules will be published in the near future.
2021-09-14Report coverage for all classes on the classpathFabian Meumertzheim
Using the (very fast) classpath traverser ClassPath, we can generate coverage data for *all* classes on the classpath rather than just those that were loaded during the fuzzing run.
2021-08-13Make libFuzzer checkout smaller by stripping pathsFabian Meumertzheim
2021-08-13Do not build unused shared librariesFabian Meumertzheim
2021-08-09Fix visibility of //third_party:uses_toolchainFabian Meumertzheim
2021-08-09Use an LLVM Bazel toolchain in the CIFabian Meumertzheim
The toolchain is only enabled in the CI by default as users should use the same compiler toolchain for compiling the Jazzer driver as they use to compile their JNI libraries. However, if they are only interested in fuzzing pure Java libraries, they can pass --config=ci on the CLI to use the toolchain, which greatly simplifies the build on macOS. A significant complication arises because the ASan runtime library can't be linked statically on macOS. To make the tests pass, it needs to be exported from the toolchain and the driver has to conditionally depend on it explicitly. A further patch to the toolchain is required to ensure compatibility with Ubuntu 21.04.
2021-08-09Find libjvm with a repository ruleFabian Meumertzheim
libjvm lives in different subpaths of JAVA_HOME, depending both on the OS and the Java version. Since it is currently not possible to select a dependency based on the Java version, supporting Java 8 required a custom build setting. This also broke bazel query (but not cquery). By loading libjvm from a simple repository rule, we can cover all OSes and Java versions with a single dependency, even if libjvm.so is installed in a non-standard location.
2021-07-11Restore g++ compatibilityFabian Meumertzheim
Also moves the quote command args patch upstream.
2021-05-27Pass quoted arguments to child processesFabian Meumertzheim
libFuzzer does not quote the arguments it passes to child processes during merge and fork, which leads to arguments being lost if passing multiple jvm_args with delimiter ';'. This commit adds a libFuzzer patch that properly quotes all arguments as well as a test that fails if quoting is not appropriate.
2021-05-12Update libFuzzerFabian Meumertzheim
Our libFuzzer fork has been updated as some of our patches have been upstreamed. It now also includes the get-covered-pcs patch.
2021-05-06Update rules_foreign_cc and fix TurboJpeg buildFabian Meumertzheim
2021-05-06Simplify Bazel handling of JNI headersFabian Meumertzheim
Use a Bazel provided target for the JNI headers instead of a custom one.
2021-04-26Add option to generate coverage reportFabian Meumertzheim
The new --coverage_report option triggers a coverage report to be written on fuzzer exit. The report is generated with the JaCoCo analyzer. The information about observed coverage IDs is obtained from libFuzzer and combined with the coverage obtained during fuzzerInitialize as well as the current run.
2021-04-26Refactor JaCoCo coverage instrumentationFabian Meumertzheim
In order to make our coverage information usable by the analyzer, probe events need to be emitted by the MethodProbesAdapter rather than the ProbeInserter. This commit moves the events to that class and simplifies the code in EdgeCoverageInstrumentor.
2021-04-26Use workspace macros for external dependenciesFabian Meumertzheim
2021-04-26Fix header layering violationsFabian Meumertzheim
2021-04-21Delete redundant patch filesFabian Meumertzheim
These have been integrated into the fork.
2021-04-21Mark non-Java 8 targets as manualFabian Meumertzheim
2021-04-21Adjust path to libjvm with JDK 8Fabian Meumertzheim
2021-03-24Use correct path to libjvm for macOSFabian Meumertzheim
2021-03-22Do not intercept JVM-internal C stdlib callsFabian Meumertzheim
The JVM frequently calls strcmp/memcmp/..., which fills up the table of recent compares with entries that are either duplicates of values already reported by the bytecode instrumentation or JDK-internal strings that are not relevant for fuzzing. This commit adds an ignorelist to the C stdlib interceptors that filters out calls from known JVM libraries. If the fuzz target has not yet loaded a native library, all such callbacks are ignored, which greatly improves fuzzer performance for string-heavy targets. E.g., JsonSanitizerDenylistFuzzer takes < 1 million runs now when it used to take over 3 million.
2021-03-22Replace -Wl,--wrap with a source code patchFabian Meumertzheim
2021-03-22Build libFuzzer from sourceFabian Meumertzheim
Building libFuzzer from source is easy and has multiple advantages: * The clang distributed with XCode on macOS does not include libFuzzer. * Applying a small patch to libFuzzer will allow us to replace the --wrap linker feature, which is not supported on platforms other than Linux.
2021-03-22Run buildifier --lint=fix -r .Fabian Meumertzheim
2021-03-22Revert "Do not intercept JVM-internal C stdlib calls (#45)"Fabian Meumertzheim
This reverts commit 71ac55c6fc9d808bcc8a8e8d895f7f20141bec86.
2021-03-22Do not intercept JVM-internal C stdlib calls (#45)Fabian Meumertzheim
* Replace uses of quick_exit and at_quick_exit quick_exit is not supported on macOS, but can easily replaced by a call to _Exit after running our cleanup manually. * Run buildifier --lint=fix -r . * Build libFuzzer from source Building libFuzzer from source is easy and has multiple advantages: * The clang distributed with XCode on macOS does not include libFuzzer. * Applying a small patch to libFuzzer will allow us to replace the --wrap linker feature, which is not supported on platforms other than Linux. * Replace -Wl,--wrap with a source code patch * Pin non-native rules_python * Print exit code on test failure * Do not intercept JVM-internal C stdlib calls The JVM frequently calls strcmp/memcmp/..., which fills up the table of recent compares with entries that are either duplicates of values already reported by the bytecode instrumentation or JDK-internal strings that are not relevant for fuzzing. This commit adds an ignorelist to the C stdlib interceptors that filters out calls from known JVM libraries. If the fuzz target has not yet loaded a native library, all such callbacks are ignored, which greatly improves fuzzer performance for string-heavy targets. E.g., JsonSanitizerDenylistFuzzer takes < 1 million runs now when it used to take over 3 million.
2021-02-22Instrument edges instead of basic blocksFabian Meumertzheim
We are currently deriving edge coverage instrumentation from basic block instrumentation via the AFL XOR-technique. This has several downsides: * Different edges can be assigned the same position in the coverage map, which leads to underreported coverage. * The coverage map needs to be large enough for collisions to be unlikely (on the order of num_edges^2). In addition to being wasteful, it is also hard to determine the correct size given that we don't know the number of edges. In addition to the design limitations, the current implementation additionally does not take into account that most Java method invocations can throw exceptions and thus need to be instrumented. These issues are resolved by switching to true LLVM-style edge coverage instrumentation. The new coverage instrumentation is based on a lightly patched version of the JaCoCo internals. Note: //agent/src/test/java/com/code_intelligence/jazzer/instrumentor:coverage_instrumentation_test is not passing for this commit. It will be fixed with the next commit.
2021-02-09Initial commitFabian Meumertzheim