Skip to content

Refactor infra of Go 1.18 fuzzers - #8937

Merged
AdamKorcz merged 12 commits into
google:masterfrom
AdamKorcz:infra-native-fuzzing
Nov 21, 2022
Merged

AdamKorcz merged 12 commits into
google:masterfrom
AdamKorcz:infra-native-fuzzing

Conversation

@AdamKorcz

Copy link
Copy Markdown
Collaborator

go-118-fuzz-build is undergoing refactoring to fix some runtime issues affecting Rekor and other projects. Currently none of Rekors fuzzers run. This PR has been tested on all of Rekors fuzzers that will run with this PR.

This PR modifies the infra OSS-Fuzz build script to adapt to the upstream changes.

Cloning the dev branch of go-118-fuzz-build is a temporary solution until it gets merged into main upstream.
Cloning go-118-fuzz-build in each build script is also a temporary measure until dev gets merged into main.

Signed-off-by: AdamKorcz [email protected]

@AdamKorcz
AdamKorcz force-pushed the infra-native-fuzzing branch 3 times, most recently from 5c545f9 to 5d4c8e3 Compare November 7, 2022 22:38
@AdamKorcz

AdamKorcz commented Nov 7, 2022 •

Copy link
Copy Markdown
Collaborator Author

@Navidem This one should go green. Could you review?

@oliverchang oliverchang left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thank you for fixing! would you mind summarizing the actual fixes in the PR description to give us a bit more context?

e.g. I see rewrite_go_fuzz_harness got removed. What upstream change led to removing this?

@AdamKorcz

AdamKorcz commented Nov 8, 2022 •

Copy link
Copy Markdown
Collaborator Author

thank you for fixing! would you mind summarizing the actual fixes in the PR description to give us a bit more context?

e.g. I see rewrite_go_fuzz_harness got removed. What upstream change led to removing this?

Sure, the changes in this PR are 3-fold:

  1. Update the compile_native_go_fuzzer script to accomodate upstream changes.
  2. Update projects with new changes.
  3. Temporarily disable the coverage build of native go fuzzers.

1: Update the compile_native_go_fuzzer script to accomodate upstream changes.
Several features that were found in compile_native_go_fuzzer have been moved to the go-118-fuzz-build binary. The two biggest changes are:

  1. Harness modification: Some OSS-Fuzz projects have moved their test utils out of the fuzzers, and the rewrite-script in compile_native_go_fuzzer does not modify those test utils. Istio is an example of that which results in crashes like this: https://oss-fuzz.com/testcase-detail/6582039348641792. go-118-fuzz-build has been updated to modify the fuzzer and all of its dependencies by traversing the fuzzers and its dependecies' AST. This file in go-118-fuzz-build does that. The addimport binary has also been removed.
  2. Better support for testing APIs. More OSS-Fuzz projects are now writing fuzzers with std lib testing utils like t.Skip() which were not supported in go-118-fuzz-build. I have added support for these in go-118-fuzz-build in a way that makes sense for libFuzzer. This can be found here: https://github.com/AdamKorcz/go-118-fuzz-build/tree/dev/testing. This is for example an issue for Rekor which breaks the fuzzers at runtime.

2: Update projects with new changes
This part adjusts the projects in OSS-Fuzz using github.com/AdamKorcz/go-118-fuzz-build in their build scripts. The biggest change is to the paths:

  1. .../testingtypes -> .../testing
  2. .../utils -> .../testing

3: Modify the coverage build of native go fuzzers
The current Go coverage build implements a wrapper around the fuzzers, but as of Go 1.18, this is not necessary. This PR removes that wrapper and passes the corpus directly to the fuzzers. To do this, I have written a tool that converts libFuzzer corpus to native Go corpus.

@AdamKorcz
AdamKorcz marked this pull request as draft November 8, 2022 22:53
@AdamKorcz
AdamKorcz force-pushed the infra-native-fuzzing branch 3 times, most recently from 1ada7aa to b358c77 Compare November 10, 2022 20:41
@AdamKorcz
AdamKorcz marked this pull request as ready for review November 12, 2022 17:56
@AdamKorcz

Copy link
Copy Markdown
Collaborator Author

@oliverchang As discussed, I have fixed the coverage build instead of deferring it to a future PR. Could you review?

@oliverchang oliverchang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks! This LGTM with just two more comments/questions.

Comment thread infra/base-images/base-runner/coverage Resolved

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we expect the dev branch changes to be merged into the main branch soon?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes. That should happen by end of month.

@AdamKorcz
AdamKorcz force-pushed the infra-native-fuzzing branch from 871ed89 to 444f794 Compare November 14, 2022 09:52
@oliverchang

Copy link
Copy Markdown
Collaborator

/gcbrun trial_build.py smt helm moby go-dns go-coredns istio --sanitizer address --fuzzing-engine libfuzzer

@oliverchang

Copy link
Copy Markdown
Collaborator

From the trial build,

istio is failing with many instances of:

+ compile_native_go_fuzzer istio.io/istio/pilot/pkg/security/authz/builder FuzzBuildTCP FuzzBuildTCP
pkg/config/mesh/fuzz_test.go_fuzz.go:3:8: no required module provides package github.com/AdamKorcz/go-118-fuzz-build/testing; to add it:
	go get github.com/AdamKorcz/go-118-fuzz-build/testing

helm is failing with many instances of:

Running go-fuzz -tags gofuzz -func FuzzIndexDirectory -o fuzz_index_directory.a helm.sh/helm/v3/pkg/repo
+ compile_go_fuzzer helm.sh/helm/v3/pkg/repo FuzzDownloadIndexFile fuzz_download_index_file
/usr/local/bin/compile_go_fuzzer: line 28: cd: /root/go/src/helm.sh/helm/v3/pkg/repo: No such file or directory

These appear to be passing normally without this PR.

@AdamKorcz is this expected? can you please investigate?

@AdamKorcz

AdamKorcz commented Nov 15, 2022 •

Copy link
Copy Markdown
Collaborator Author

From the trial build,

istio is failing with many instances of:

+ compile_native_go_fuzzer istio.io/istio/pilot/pkg/security/authz/builder FuzzBuildTCP FuzzBuildTCP
pkg/config/mesh/fuzz_test.go_fuzz.go:3:8: no required module provides package github.com/AdamKorcz/go-118-fuzz-build/testing; to add it:
	go get github.com/AdamKorcz/go-118-fuzz-build/testing

helm is failing with many instances of:

Running go-fuzz -tags gofuzz -func FuzzIndexDirectory -o fuzz_index_directory.a helm.sh/helm/v3/pkg/repo
+ compile_go_fuzzer helm.sh/helm/v3/pkg/repo FuzzDownloadIndexFile fuzz_download_index_file
/usr/local/bin/compile_go_fuzzer: line 28: cd: /root/go/src/helm.sh/helm/v3/pkg/repo: No such file or directory

These appear to be passing normally without this PR.

@AdamKorcz is this expected? can you please investigate?

Yes it is expected.

Istio and Helm need similar updates as the OSS-Fuzz build scripts(change /utils to /testing). I have pushed an example of that directly in the Istio build and pointed Helm to a branch where it is fixed. Istio needs a bit more work with these 3 fuzzers, but I think it is better to do that upstream. The current state of this PR should show that Istios and Helms errors quoted above have been fixed; In the logs, I only see that Istio is failing:

libfuzzer, address, x86_64
Failed projects: istio

libfuzzer, coverage, x86_64
Failed projects: istio

Naturally I will adjust the upstream build scripts of all projects running native Go fuzzers.

@oliverchang

Copy link
Copy Markdown
Collaborator

From the trial build,
istio is failing with many instances of:

+ compile_native_go_fuzzer istio.io/istio/pilot/pkg/security/authz/builder FuzzBuildTCP FuzzBuildTCP
pkg/config/mesh/fuzz_test.go_fuzz.go:3:8: no required module provides package github.com/AdamKorcz/go-118-fuzz-build/testing; to add it:
	go get github.com/AdamKorcz/go-118-fuzz-build/testing

helm is failing with many instances of:

Running go-fuzz -tags gofuzz -func FuzzIndexDirectory -o fuzz_index_directory.a helm.sh/helm/v3/pkg/repo
+ compile_go_fuzzer helm.sh/helm/v3/pkg/repo FuzzDownloadIndexFile fuzz_download_index_file
/usr/local/bin/compile_go_fuzzer: line 28: cd: /root/go/src/helm.sh/helm/v3/pkg/repo: No such file or directory

These appear to be passing normally without this PR.
@AdamKorcz is this expected? can you please investigate?

Yes it is expected.

Istio and Helm need similar updates as the OSS-Fuzz build scripts(change /utils to /testing). I have pushed an example of that directly in the Istio build and pointed Helm to a branch where it is fixed. Istio needs a bit more work with these 3 fuzzers, but I think it is better to do that upstream. The current state of this PR should show that Istios and Helms errors quoted above have been fixed; In the logs, I only see that Istio is failing:

libfuzzer, address, x86_64 Failed projects: istio

libfuzzer, coverage, x86_64 Failed projects: istio

Naturally I will adjust the upstream build scripts of all projects running native Go fuzzers.

Thanks. If other breakages are expected, can we please have those fixes ready to go with this PR? IT wouldn't be good if we start spamming oss-fuzz users with build failure emails because of our own breakage.

Comment thread projects/istio/build.sh Resolved
@AdamKorcz

Copy link
Copy Markdown
Collaborator Author

I have gone through all Go projects and found that 3 (besides those fixed in this PR) would break from this PR. I have created a draft with a fix on those projects:

I have removed the Istio fix from this PR.

@oliverchang

Copy link
Copy Markdown
Collaborator

OK, thanks! Please merge this whenever you're ready. We should aim to merge the three fixes you listed as soon as this one lands.

@AdamKorcz
AdamKorcz force-pushed the infra-native-fuzzing branch from b524594 to 019096d Compare November 18, 2022 11:39
…h github.com/AdamKorcz/go-118-fuzz-build/testing

Signed-off-by: AdamKorcz <[email protected]>
Signed-off-by: AdamKorcz <[email protected]>
Signed-off-by: AdamKorcz <[email protected]>
@RiSKeD

RiSKeD commented Nov 28, 2022

Copy link
Copy Markdown
Contributor

@AdamKorcz Would it be possible for you to take a look at the build script of the u-root project as well?
I tried updating the build script after the changes, but it fails to build some of the targets.

@AdamKorcz

Copy link
Copy Markdown
Collaborator Author

@AdamKorcz Would it be possible for you to take a look at the build script of the u-root project as well? I tried updating the build script after the changes, but it fails to build some of the targets.

Will do

Navidem pushed a commit that referenced this pull request Dec 1, 2022
#8937 cloned go-118-fuzz-build
from the `dev` branch. This PR reverts that since `dev` has been merged
into `master`.

Signed-off-by: AdamKorcz <[email protected]>

Signed-off-by: AdamKorcz <[email protected]>
oliverchang added a commit that referenced this pull request Dec 20, 2022
Fixes:
#8937 (comment)

Signed-off-by: AdamKorcz <[email protected]>

Signed-off-by: AdamKorcz <[email protected]>
Co-authored-by: Oliver Chang <[email protected]>
@catenacyber

Copy link
Copy Markdown
Contributor

#9808 looks caused by this

Why should we have coverage only for native fuzzing @AdamKorcz ?

jonathanmetzman pushed a commit that referenced this pull request Feb 28, 2023
@AdamKorcz what do you think of these commits ?

cf #8937 and should fix
#9808
eamonnmcmanus pushed a commit to eamonnmcmanus/oss-fuzz that referenced this pull request Mar 15, 2023
`go-118-fuzz-build` is undergoing refactoring to fix some runtime issues
affecting Rekor and other projects. Currently none of Rekors fuzzers
run. This PR has been tested on all of Rekors fuzzers that will run with
this PR.

This PR modifies the infra OSS-Fuzz build script to adapt to the
upstream changes.

Cloning the `dev` branch of `go-118-fuzz-build` is a temporary solution
until it gets merged into `main` upstream.
Cloning go-118-fuzz-build in each build script is also a temporary
measure until `dev` gets merged into `main`.

Signed-off-by: AdamKorcz <[email protected]>

Signed-off-by: AdamKorcz <[email protected]>
eamonnmcmanus pushed a commit to eamonnmcmanus/oss-fuzz that referenced this pull request Mar 15, 2023
google#8937 cloned go-118-fuzz-build
from the `dev` branch. This PR reverts that since `dev` has been merged
into `master`.

Signed-off-by: AdamKorcz <[email protected]>

Signed-off-by: AdamKorcz <[email protected]>
eamonnmcmanus pushed a commit to eamonnmcmanus/oss-fuzz that referenced this pull request Mar 15, 2023
Fixes:
google#8937 (comment)

Signed-off-by: AdamKorcz <[email protected]>

Signed-off-by: AdamKorcz <[email protected]>
Co-authored-by: Oliver Chang <[email protected]>
eamonnmcmanus pushed a commit to eamonnmcmanus/oss-fuzz that referenced this pull request Mar 15, 2023
@AdamKorcz what do you think of these commits ?

cf google#8937 and should fix
google#9808
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.

4 participants