https://opendal.apache.org/ logo
OSPP 2023 Project: OSS Fuzz Support
# general
x
cc @User @dqhl76
If necessary, we can discuss the details here. Alternatively, feel free to contact us via Github or Maillist - whichever method you prefer.
d
Sure. Happy to know it. 🥳 In the next few days I will organize my proposal and put a brief version on Github.
x
You can start a new tracking issue for this project if needed🥰
d
Hi, @Xuanwo . When I write the fuzz checker. I found some problems. I want to check
seek
operation, but I found the invalid parameter(negative value) will cause panic. I firstly thought that
seek
will return a
Result
and I can handle it like that https://gist.github.com/dqhl76/76cdb6364339ced8867db8eafdd7b7c2. But I now realize I can't do that 🥲, do you have any suggestions on how to deal with invalid input data?
x
> but I found the invalid parameter(negative value) will cause panic.
Congrats, you catch the first bug of OpenDAL (even without the first run of fuzz)
I believe it's more like a bug we need to address (
It's possible that users can
let r = op.reader("path/to/file")
and than
r.seek(SeekFrom::Current(-1024))
.
We should not panic here.
Would you like to submit an issue to OpenDAL? Some internal logic should be changed and I think we can add a new behavior test like:
Copy code
rust
let r = op.reader("path/to/file")
r.seek(SeekFrom::Current(-1024))
we should get an error instead of panic.
cc @dqhl76 for ping
d
Got that. I will submit a issue this afternoon. Understand the meaning of “If you want to become a contributor to an open source project, you first need to become a user of the project.”🥰
It is actually not a panic, I think it may be my checker's problem. I will submit a PR to make
Unexpected
to
InvalidInput
and continue the fuzz test work. Sorry for wasting your time
x
Never mind, mistakes are always part of the exploration process!
d
Hi @Xuanwo Could you please take a look when you are available. Thanks for your review.🥰https://github.com/apache/incubator-opendal/pull/2609
x
DONE! Great work!
d
Hi @Xuanwo . I found that https://github.com/apache/incubator-opendal/actions/runs/5573356275/jobs/10180524092 made
cargo
give our a warning
Copy code
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /Users/lqyue/githubProjects/incubator-opendal/core/fuzz/Cargo.toml
workspace: /Users/lqyue/githubProjects/incubator-opendal/Cargo.toml
After some search, I found I should remove
[profile.release]
in
/core/fuzz/Cargo.toml
. Should I submit a PR right now or fix it on next PR for the new feature?
x
It's better to submit a PR now if you have free time.
d
x
Nice mind! Everyone is trying our best to make OpenDAL better. There is no need far sry.
d
Hi, @Xuanwo . Could you please take a review again? https://github.com/apache/incubator-opendal/pull/2706
x
Great work!
d
Thanks!

https://cdn.discordapp.com/attachments/1122785258501308497/1133217750211367044/image.png▾

I think we may finish this part. Do you have any comments?
x
I expect we can running fuzz test in our own CI first.
we can have a fuzz_test.yml in which we hold all services fuzz test.
we can test upon fs / memory / s3 (with minio) first
d
Yes. I will try it !!!
x
It's better for our fuzz test can finish in 5 minutes (don't block our PR)
Which requires our fuzz count can be configured 😃
d
cargo fuzz run fuzz_range_reader -- -max_total_time=200
we can use some config like this
x
Wow, better than I can imagine

https://cdn.discordapp.com/attachments/1122785258501308497/1133220462076379168/image.png▾

@dqhl76 1500th commit!
d
Wow!
Hi @Xuanwo I tried to add CI for the fuzz test. Unfortunately, it takes us 8 mins (around 5 min for build, only 2 min for test
-max_total_time=150
). This is the test action history https://github.com/dqhl76/incubator-opendal/actions/runs/5657272294/job/15325961782 and the workflow file https://github.com/dqhl76/incubator-opendal/actions/runs/5657272294/workflow. Do you have any method to speed up the building process?
I tried some methods (e.g add
development -D
flag) to speed up from 12 mins to 8 mins but it is still too slow.
🤯
Maybe we should only trigger this action daily or when release (not block the pr)
x
Every PR, just like other services test.
The
not block the pr
means not running too long (like half an hour)
d
👌
x
Hi, @dqhl76, do you know how to use cargo fuzz fmt?
I tried
fuzz-test-run-fs (fuzz_range_reader)
, but there is no output.
d
cargo fuzz fmt fuzz_range_reader /Users/lqyue/CLionProjects/incubator-opendal/crash-a43d017086414fd4425807171257611ddfcc3122
Like this
or just use
cargo fuzz run fuzz_range_reader /Users/lqyue/CLionProjects/incubator-opendal/crash-a43d017086414fd4425807171257611ddfcc3122
it will also print it
x
Let me have a try!
the format like this
x
d

https://cdn.discordapp.com/attachments/1122785258501308497/1133696863082659870/image.png▾

x
Nice!
d
I find it seem caused by a invalid seek
x
btw, the crash file is so small..
d
let me download and check it
x

https://cdn.discordapp.com/attachments/1122785258501308497/1133697084944560158/image.png▾

wow, it works
by the way, would you like to write a blog about opendal fuzzing test?
what's fuzz, how we implemented it, and how to use it for debugging
It must be cool!
d
Sure! may be after we finally merge it into oss-fuzz

https://cdn.discordapp.com/attachments/1122785258501308497/1133697801784664064/image.png▾

it works! The file size is not a problem
x
This case is really interesting:
Copy code
rust
range: (
                130,
                131,
            ),
read a file with range 130 - 131
d
just one byte?
x
yep
this is the fuzzing power
We will never have test cases like this...
d
https://github.com/apache/incubator-opendal/pull/2710 Do you have any great method to improve the build speed?
x
, not yet.
d
Alright. It takes 10 mins to build and just 2 mins to run the test. I think it is little bit (...本末倒置 cannot find a word in english :D)
x
I don't know why cargo fuzz build is so slow...
Ok, I fixed this case.
d
Wow, so quick. Do you think could we add some cache strategies to make the build process more quick?
x
Good to have, but I'm afraid that there is few things that we can cache.
Maybe we can run those fuzzing timely like everyday night, instead of every PR.
I will try this as a research purpose. If it cannot work, may be fuzzing timely is a better choice
x
We can merge this PR first~
So the crash file doesn't store the real input
Instead, it stores a random seed by which we can build the same input
d
I think is
seed+mutation
Every time we run
cargo fuzz run
. It will select a seed and then mutate the input by some strategy
x
Looking forward to your blog about fuzzing!
d
interesting~
The output of fuzzing test is really great!
😋 , our fuzzing test loop seems cool - fuzzing on services we most used: fs, s3, memory (maybe others in the future) - store the crash files while failed - reproduce the crash and trying to fix it. - unstranding what happend and extract as a behavior test to cover all our services
d
I think I may need to change the README in core/fuzz
x
Oh, I got it.
The slowest part is building libfuzzer
Let's try using the system libfuzzer instead.
d
Sry I didn't get the point.. I didn't find a option in
cargo fuzz build
to skip libfuzzer build.

https://cdn.discordapp.com/attachments/1122785258501308497/1134090072082358374/image.png▾

x
It's not an option, it's libfuzzer-sys't build.rs logic.
We speed up about 2 minutes 😋
d
I have some concerns about how do we handle the crash file. Seems we don't need them?
x
Yes, they are printed as base64 at the end of crash which is much easier to copy directly.
The key idea here is the data in file doesn't make different for our fuzzing test.
So we don't need to store the actual data in
FuzzInput
, instead, we store a
total_size
.
d
Thoroughly understood.
Hi @Xuanwo. The files that need to be submitted to ossfuzz's repo are ready. https://github.com/dqhl76/opendal-ossfuzz Could you please take a look? I am not sure about the contact information part.

https://cdn.discordapp.com/attachments/1122785258501308497/1136837578499305603/image.png▾

I have run the
check build
locally. It seems no problem.
x
primary_contact seems need to be
dev@opendal.apache.org
?
It need to be a google account
I am not sure if we can create a google account for dev@o.a.o
x
no, we can't.
ok, let's use xuanwo.cn@gmail.com here.
auto_ccs should be
dev@opendal.apache.org
d

https://cdn.discordapp.com/attachments/1122785258501308497/1136842172566605834/image.png▾

sry. It also need to be a google account

https://cdn.discordapp.com/attachments/1122785258501308497/1136842262207279234/image.png▾

vendor css has no limitation.
x
ok
vendor should be
commits@opendal.apache.org
d
Got that.
x
others LGTM
great work!
d
Do you think whether we should add a option
file_github_issue
It could allow us mirror the problem report in github issues
x
Yes, we need it.
d
I will give a pr for oss-fuzz repo these days. It may need a opendal committer to permit it. I may need
/cc
you in that. 🥰
x
I'm glad to help do that!
d
Sorry, I think we cannot add s3(minio) for OSS-fuzz. https://google.github.io/oss-fuzz/further-reading/fuzzer-environment/ They use two environment, one for building target, another for running target. We can only control the environment in building environment via dockerfile. However, in running environment, we can only access /tmp dict. Please check the document. cc @User
After building process, they move to $OUT directory. After that, we seem cannot control them.
x
We can install minio in docker directly and start it in background?
d
I am not sure about this line
Copy code
Install the packages via Dockerfile (example) and then link statically against them (example).
Could we do that by statically link them?
x
I'm guessing you are over thinking about this.
link statically is for opendal's fuzz target, so that it's runnable after moving to $OUT
d
Packages that are installed via Dockerfile or built as part of build.sh are not available on the bot runtime environment (where the fuzz targets run).
According to that, what we do in dockerfile cannot impact the runtime environment.
Maybe I misunderstand what you mean?🥴
x
🤔 , if so, adding
.env
in
$SRC/opendal/.env
should be a no-op
Since it's not copied to $OUT
d
🤯
x
I'm not sure if copying .env to $OUT works. If not, maybe we need to adjust our fuzzer to allow it works under oss-fuzz
d
Maybe add default env value.
Let me do some tests
x
Seems we can use
python infra/helper.py run_fuzzer
for testing locally.
d
I am doing that
All build artifacts needed during fuzz target execution should be inside the $OUT directory. Only those artifacts are archived and used on the bots.
According to that, copy .env to $OUT cannot work
Alas~😖 I struggled with various methods, and it seems that the only way is to add default values ​​​​to the process of fuzz services init on our side.
It's my problem, I didn't understand the documentation of ossfuzz.
I will submit a PR for opendal to add the default value and update the document
x
never mind, let's figure out it.
I don't think it's a good way since fuzz could be run by different users.
Think about it: not everyone want to run fuzz with fs under /tmp.
Windows users ever don't have
/tmp
.
d
Yes. Do we have some ways to bind a env value to a executable file? I search for the website and not find a nice way
x
It's possible by using
include_str!()
Maybe we should generate different targets on needs.
Ok, I got it. We can use
include_str!(".env")
to include .env in binary and use
dotenvy
to parse them. In our CI it should be no changes. And in OSS-Fuzz, we will build targets in mulitple times. - add memory settings in .env - cargo fuzz build, and rename targets to fuzz_reader_memory - add fs settings in .env - cargo fuzz build, and rename targets to fuzz_reader_fs So we can test different targets.
d
Got that. I will try to do that. 🚀 Thanks for your advice!
x
btw, are you sure that .env will be removed in $OUT?
I re-visit the docs, it seems we can keep .env in $OUT
And the problem is that we did't read it
d
Could you please give me the link?
x

https://cdn.discordapp.com/attachments/1122785258501308497/1138302542577680394/image.png▾

d
I thought it means only the executable files will be archived. It is easy to test. Let me confirm it.
find $OUT/ -executable -type f
It will only move executable file into running container
x
find is just find, all files under $OUT already been uploaded.
seems we can use fuzz_reader_memory.options to carry what we want.
- cargo fuzz build - add memory settings in fuzz_reader_memory.options - copy fuzz_reader to fuzz_reader_memory - add fs settings in fuzz_reader_fs.options - copy fuzz_reader to fuzz_reader_fs
much better!
d

https://cdn.discordapp.com/attachments/1122785258501308497/1138308619448877086/image.png▾

I think too much. We seem just need to copy
.env
to
$OUT
I think spliting them is better. I will try it later
x
problem is fuzz doesn't read .env 😁
d
Yes. To make it same with our behaviour test
Hi @Xuanwo. I submitted a PR, would you like to take a look?
x
🤔 , why we need this?
d
Reply on GitHub
x
d
Yes. And the result stat has no display since their problem
I think we cannot use
dotenvy::from_filename_override(".fs.env")
. although it is very elegant
Submit a new PR on OSS-fuzz side to address the environment problem we discussed: https://discord.com/channels/1081052318650339399/1122785258501308497/1138286508357472366 https://github.com/google/oss-fuzz/pull/10814 Ping @Xuanwo
21 Views