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

infra: refine fuzztest work #8992

Merged
merged 13 commits into from
Nov 28, 2022
Merged

infra: refine fuzztest work #8992

merged 13 commits into from
Nov 28, 2022

Conversation

DavidKorczynski
Copy link
Collaborator

@DavidKorczynski DavidKorczynski commented Nov 16, 2022

Enable Fuzztest fuzzers for Tensorflow.

This depends on google/fuzztest#79 and eventually a PR on the tensorflow repo with the (to be refined) diff in this PR.

Signed-off-by: David Korczynski david@adalogics.com

This is draft.

Signed-off-by: David Korczynski <david@adalogics.com>
This is needed for tensorflow.

Signed-off-by: David Korczynski <david@adalogics.com>
@DavidKorczynski
Copy link
Collaborator Author

Compiling, running and extracting coverage of the tensorflow fuzztest fuzzers work:

tensorflow-fuzztest-coverage

Some refinement and cleanup is needed.

Cleanup is needed.

Signed-off-by: David Korczynski <david@adalogics.com>
Signed-off-by: David Korczynski <david@adalogics.com>
DavidKorczynski added a commit to DavidKorczynski/fuzztest that referenced this pull request Nov 16, 2022
Split between CFLAGS and CXXFLAGS. This is needed to make tensorflow
work.

Related: google/oss-fuzz#8992

Signed-off-by: David Korczynski <david@adalogics.com>
DavidKorczynski added a commit to DavidKorczynski/fuzztest that referenced this pull request Nov 16, 2022
Split CFLAGS and CXXFLAGS into language-specific bazel constructs. This
is needed to make Tensorflow work.

Related: google/oss-fuzz#8992

Signed-off-by: David Korczynski <david@adalogics.com>
@DavidKorczynski
Copy link
Collaborator Author

CI is failing because of timeouts, however, in UBSAN we get past the point where the UBSAN FuzzTest fuzzers are build (showing the building works):

2022-11-16T23:47:38.9367669Z �[32m[565 / 565]�[0m checking cached actions
2022-11-16T23:47:38.9442114Z 
2022-11-16T23:47:38.9442589Z �[1A�[K�[32mINFO:�[0m Build completed successfully, 565 total actions
2022-11-16T23:47:38.9442820Z 
2022-11-16T23:47:38.9443069Z �[1A�[K�[32mINFO:�[0m Build completed successfully, 565 total actions
2022-11-16T23:47:38.9453814Z �[0m+ for fuzz_main_file in $FUZZ_TEST_BINARIES_OUT_PATHS
2022-11-16T23:47:38.9461793Z ++ bazel-out/k8-opt/bin/tensorflow/security/fuzzing/cc/status_fuzz --list_fuzz_tests
2022-11-16T23:47:38.9522466Z + FUZZ_TESTS=CC_FUZZING.FuzzTest
2022-11-16T23:47:38.9522995Z + cp bazel-out/k8-opt/bin/tensorflow/security/fuzzing/cc/status_fuzz /out/
2022-11-16T23:47:38.9704946Z ++ basename bazel-out/k8-opt/bin/tensorflow/security/fuzzing/cc/status_fuzz
2022-11-16T23:47:38.9721314Z + fuzz_basename=status_fuzz
2022-11-16T23:47:38.9721686Z + chmod -x /out/status_fuzz
2022-11-16T23:47:38.9739806Z + for fuzz_entrypoint in $FUZZ_TESTS
2022-11-16T23:47:38.9740158Z + TARGET_FUZZER=status_fuzz@CC_FUZZING.FuzzTest
2022-11-16T23:47:38.9740499Z + echo '#!/bin/sh
2022-11-16T23:47:38.9740767Z # LLVMFuzzerTestOneInput for fuzzer detection.
2022-11-16T23:47:38.9741036Z this_dir=$(dirname "$0")
2022-11-16T23:47:38.9741259Z chmod +x $this_dir/status_fuzz
2022-11-16T23:47:38.9741603Z status_fuzz --fuzz=CC_FUZZING.FuzzTest -- $@'
2022-11-16T23:47:38.9741900Z + chmod +x /out/status_fuzz@CC_FUZZING.FuzzTest
2022-11-16T23:47:38.9746754Z + for fuzz_main_file in $FUZZ_TEST_BINARIES_OUT_PATHS
2022-11-16T23:47:38.9750779Z ++ bazel-out/k8-opt/bin/tensorflow/security/fuzzing/cc/parseURI_fuzz --list_fuzz_tests
2022-11-16T23:47:38.9794784Z + FUZZ_TESTS=CC_FUZZING.FuzzTest
2022-11-16T23:47:38.9795308Z + cp bazel-out/k8-opt/bin/tensorflow/security/fuzzing/cc/parseURI_fuzz /out/
2022-11-16T23:47:38.9876186Z ++ basename bazel-out/k8-opt/bin/tensorflow/security/fuzzing/cc/parseURI_fuzz
2022-11-16T23:47:38.9884894Z + fuzz_basename=parseURI_fuzz
2022-11-16T23:47:38.9885275Z + chmod -x /out/parseURI_fuzz
2022-11-16T23:47:38.9894797Z + for fuzz_entrypoint in $FUZZ_TESTS
2022-11-16T23:47:38.9895099Z + TARGET_FUZZER=parseURI_fuzz@CC_FUZZING.FuzzTest
2022-11-16T23:47:38.9895451Z + echo '#!/bin/sh

Signed-off-by: David Korczynski <david@adalogics.com>
@DavidKorczynski DavidKorczynski marked this pull request as ready for review November 22, 2022 21:55
@DavidKorczynski DavidKorczynski changed the title infra/tensorflow: make fuzztest work infra: refine fuzztest work Nov 22, 2022
@DavidKorczynski
Copy link
Collaborator Author

@oliverchang I switched this up to focus on fuzztest as it now has a potential fix for #8997 (was missing $ in front of this_dir in the wrapper script). I can do the Tensorflow aspects, which will be only in the Tensorflow project folder afterwards when tensorflow/tensorflow#58646 is merged.

This is ready to go from my perspective.

Copy link
Collaborator

@oliverchang oliverchang left a comment

Choose a reason for hiding this comment

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

Thanks! This mostly LGTM. I think just needs some more clarification in terms of documentation.


# Bazel target names of the fuzz binaries.
FUZZ_TEST_BINARIES=$(bazel query 'kind("cc_test", rdeps(..., @com_google_fuzztest//fuzztest:fuzztest_gtest_main))')
#FUZZ_TEST_BINARIES=$(bazel query 'kind("cc_test", rdeps(..., @com_google_fuzztest//fuzztest:fuzztest_gtest_main))')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we just delete this commented line?

chmod +x $OUT/$TARGET_FUZZER
done
done

# synchronise coverage directory to bazel generated code.
if [ "$SANITIZER" = "coverage" ]
if [[ "$SANITIZER" = "coverage" && ${FUZZTEST_DO_SYNC:-"yes"} == "yes" ]]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add more details on when FUZZTEST_DO_SYNC is needed in comments here?

-e 'bazel-testlogs')"
for link in $project_folders; do
if [[ -d "${PWD}"/$link/external ]]
then
rsync -avLk "${RSYNC_FILTER_ARGS[@]}" "${PWD}"/$link/external "${REMAP_PATH}"
fi
if [[ -d "${PWD}"/$link/k8-opt ]]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Likewise here -- can you add more context in comments for future readers of this code?

@@ -15,24 +15,34 @@
#
################################################################################

set -x

if [[ ${FUZZTEST_TARGET_FOLDER:-"unset"} == "unset" ]];
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need a bit more documentation on what this is needed for.

@DavidKorczynski
Copy link
Collaborator Author

@oliverchang updated the docs, let me know what you think!

Signed-off-by: David Korczynski <david@adalogics.com>
@oliverchang
Copy link
Collaborator

/gcbrun trial_build.py all --sanitizer address --fuzzing-engine libfuzzer

@oliverchang
Copy link
Collaborator

Thanks! Let's merge this on Monday to avoid any potential breakages over the weekend.

@oliverchang
Copy link
Collaborator

/gcbrun trial_build.py all --sanitizer address --fuzzing-engine libfuzzer

@oliverchang
Copy link
Collaborator

/gcbrun trial_build.py all --sanitizer address --fuzzing-engine libfuzzer

@oliverchang
Copy link
Collaborator

trial_build failures:

Step #1: bottleneck False
Step #1: numpy False
Step #1: skia False

Errors all look like spurious unrelated. issues.

@oliverchang oliverchang merged commit 529a009 into master Nov 28, 2022
@oliverchang oliverchang deleted the tensorflow-fuzztest branch November 28, 2022 07:17
@DavidKorczynski
Copy link
Collaborator Author

@oliverchang am still not seeing results in the dashboard, is this and google/clusterfuzz#2861 deployed?

@oliverchang
Copy link
Collaborator

Thanks for flagging @DavidKorczynski. We fixed a few more issues that came up in ClusterFuzz, and things should be moving along now. We should hopefully have things visible on the dashbboard in the next day or two.

eamonnmcmanus pushed a commit to eamonnmcmanus/oss-fuzz that referenced this pull request Mar 15, 2023
Enable Fuzztest fuzzers for Tensorflow.

This depends on google/fuzztest#79 and
eventually a PR on the tensorflow repo with the (to be refined) diff in
this PR.

Signed-off-by: David Korczynski <david@adalogics.com>

Signed-off-by: David Korczynski <david@adalogics.com>
Co-authored-by: Oliver Chang <oliverchang@users.noreply.github.com>
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.

2 participants