Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuzzing Utilities, and bson2json+json2bson tools #1000

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

vector-of-bool
Copy link
Collaborator

This adds some basic fuzzing build utilities, and defines bson2json and json2bson command-line tools. This was useful in diagnosing and debugging CDRIVER-4383 and CDRIVER-3380. It replaces the prior fuzzing target file, which itself wasn't being built by any CMake code.

@vector-of-bool vector-of-bool changed the title Fuzzing Utilities, and bson2json+bson2json tools Fuzzing Utilities, and bson2json+json2bson tools May 18, 2022
Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the very late review.
This looks good. The bson2json and json2bson seem generally useful. I have a question about how to set the target properties on the fuzzer.

build/cmake/Fuzzing.cmake Show resolved Hide resolved

FUZZER_TIMEOUT (integer, seonds)
Set the maximum amount a single fuzzer task should run before the fuzzer
consideres it to be "stuck" and to generate a timeout report for the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
consideres it to be "stuck" and to generate a timeout report for the
considers it to be "stuck" and to generate a timeout report for the

COMMAND "${CMAKE_COMMAND}" -E echo
" Running fuzzer program : $<TARGET_FILE:${name}>"
COMMAND "${CMAKE_COMMAND}" -E echo
" Corpus is stored in : ${art_dir}/corpus"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" Corpus is stored in : ${art_dir}/corpus"
" Corpus is stored in : ${art_dir}corpus"

Slash is already present in ${arg_dir}.

set (src_libbson_DIST
${src_libbson_DIST_local}
${src_libbson_build_DIST}
${src_libbson_doc_DIST}
${src_libbson_examples_DIST}
${src_libbson_fuzz_DIST}
${src_libbson_src_DIST}
${src_libbson_tests_DIST}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The make-release-archive task task failure may be resolved by including bson2json.main.c and json2bson.c in the distribution tarball.

I suggest adding a CMakeLists.txt in the src/libbson/tools directory to set the variable ${src_libbbson_tools_DIST}.

executes it, but it will be EXCLUDE_FROM_ALL=TRUE if the CMake setting
ENABLE_FUZZING is not true.
]]
function (mongoc_add_fuzzer name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the run-fuzzer-bson-fuzz target expected to complete quickly? I suspect I am doing something wrong or misunderstanding. But running cmake --build cmake-build --target run-fuzzer-bson-fuzz produces this output:

% cmake --build cmake-build --target run-fuzzer-bson-fuzz                
[0/1] cd /Users/kevin.albertson/review/mongo-c-driver-1000/cmake-build/fuzze...bertson/review/mongo-c-driver-1000/cmake-build/fuzzers/bson-fuzz.out//corpus

  Running fuzzer program : /Users/kevin.albertson/review/mongo-c-driver-1000/cmake-build/fuzzers/bson-fuzz.debug
     Corpus is stored in : /Users/kevin.albertson/review/mongo-c-driver-1000/cmake-build/fuzzers/bson-fuzz.out//corpus
  Crashes will appear in : /Users/kevin.albertson/review/mongo-c-driver-1000/cmake-build/fuzzers/bson-fuzz.out/

INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 2410153351
INFO: -fork=12: fuzzing in separate process(s)
INFO: -fork=12: 0 seed inputs, starting to fuzz in /var/folders/pv/p1jss0l97mq0ddr7rjbcbdt00000gp/T//libFuzzerTemp.FuzzWithFork16948.dir
#0: cov: 0 ft: 0 corp: 0 exec/s 0 oom/timeout/crash: 0/0/0 time: 0s job: 6 dft_time: 0
INFO: log from the inner process:
INFO: Seed: 2410369315
INFO:        0 files found in /var/folders/pv/p1jss0l97mq0ddr7rjbcbdt00000gp/T//libFuzzerTemp.FuzzWithFork16948.dir/C6
INFO: DataFlowTrace: reading from '/var/folders/pv/p1jss0l97mq0ddr7rjbcbdt00000gp/T//libFuzzerTemp.FuzzWithFork16948.dir/DFT'
INFO: A corpus is not provided, starting from an empty corpus
#2      INITED exec/s: 0 rss: 29Mb
INFO: 0/0 inputs touch the focus function
INFO: 0/0 inputs have the Data Flow Trace
ERROR: no interesting inputs were found. Is the code instrumented for coverage? Exiting.
INFO: exiting: 256 time: 0s

I expected the fuzzer to run for some time, and this completed instantly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is abnormal. It means the execution is not generating any coverage data. I'll investigate when I get free time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants