Conversation
Slightly tweaked network dump of a `git clone` on a tiny repo.
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
|
I've signed the CLA. |
|
CLAs look good, thanks! |
There was a problem hiding this comment.
@pks-t - can you do a review pass on the download_refs fuzz target and see that the inits and calls are done correctly. And are you ok with this being integrated in OSS-Fuzz.
| RUN git clone --depth 1 -b oss-fuzz https://github.com/libgit2/libgit2 libgit2 | ||
| WORKDIR libgit2 | ||
|
|
||
| COPY fuzz_download_refs.cc build.sh $SRC/ |
There was a problem hiding this comment.
fuzz_download_refs.cc, build.sh and corpora should be later moved to upstram repo. See https://github.com/google/oss-fuzz/blob/master/docs/ideal_integration.md
| @@ -0,0 +1,3 @@ | |||
| homepage: "https://libgit2.github.com/" | |||
| auto_ccs: "nelhage@nelhage.com" | |||
| primary_contact: "Patrick Steinhardt <ps@pks.im>" | |||
There was a problem hiding this comment.
This needs to be just email.
| make install | ||
|
|
||
| $CXX $CXXFLAGS -std=c++11 -I"$WORK/include" \ | ||
| /src/fuzz_download_refs.cc -o $OUT/download_refs \ |
There was a problem hiding this comment.
Instead of fuzz_download_refs, better to call it download_refs_fuzzer for both filename and fuzzer name.
| static git_repository *repo = nullptr; | ||
| if (repo == nullptr) { | ||
| git_libgit2_init(); | ||
| char tmp[] = "/tmp/git2.XXXXXX"; |
There was a problem hiding this comment.
Space in /tmp is limited to 64 mb, hope this is not a blocker.
There was a problem hiding this comment.
In my tests I've yet to see this get beyond a few 10s of kb, so that should be fine.
I had left in a `-b oss-fuzz` from testing off my fork
| primary_contact: "Patrick Steinhardt <ps@pks.im>" | ||
| auto_ccs: | ||
| - "nelhage@nelhage.com" | ||
| primary_contact: "<ps@pks.im>" |
|
I'm currently out of town and thus cannot do any reviews. But
I'll do so on coming Thursday.
|
|
This target quickly dies with an OOM, but otherwise looks good. |
|
Ah, that OOM might be fixed by nelhage/libgit2@a453f6f which I added locally to test against but forgot to submit upstream. I'll send a PR to libgit2 later today. |
|
often such OOMs are easily exploitable for DDoS and are thus worth fixing for real, not just for fuzzing. |
|
Yeah, per comments there was already a deliberately-selected 4GB limit, which seems at least plausibly an OK default, but doesn't work for fuzzing. I'll open a PR and see if upstream thinks it needs to be configurable or what. |
|
I see mallocs of huge size, much more than 4Gb: |
|
The code looks fine to me, thanks for working on this, @nelhage. That being said, I'd strongly favor an implementation in C90 and avoid all usage of C++. The reason is that I'd like to pull this code into libgit2 itself at some point, such that it becomes easier for us to maintain fuzzers and/or execute them locally without having to fetch any external projects first. I don't know if it is customary to have the actual fuzzer implementation in the oss-fuzz or upstream project, though. I'd be fine with having the fuzzers here first and doing the work of pulling them up into libgit2 myself, if you wish, including the transformation to C90. Please let me know how you'd like to handle it. /cc @ethomson |
|
@pks-t Best practice (per https://github.com/google/oss-fuzz/blob/master/docs/ideal_integration.md) is for fuzzers to live in the upstream repo in the long run. I was planning to merge them here since that felt like an easier v1, and then attempt to import them into libgit2.git once everything is working. I'd be happy to port to C90 when I do so; The C++isms here are mostly overkill caused by me mostly writing C++ these days :) |
|
Let's see how it works. Most likely, it will get stuck in the OOM above and that will have to be fixed in order to proceed. |
|
And here it is: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9402 |
|
I've got a PR out that will fix it, pending some design discussion: libgit2/libgit2#4721 If we can't sort a proper API soon I might re-propose a fuzzer ifdef as an interim fix. |
* Add a libgit2 fuzzer for the `git fetch` client * Use a fresh remote each time * Build fewer things, use fewer deps * no ssh, either * Add a corpus with one file. Slightly tweaked network dump of a `git clone` on a tiny repo. * auto_ccs is a list * Rename the fuzzer * only email in project.yaml * Use `master` I had left in a `-b oss-fuzz` from testing off my fork
Add an initial libgit2 fuzzer for the
git fetchclient. This has found a number of bugs already in local running:I am not a libgit2 developer, but upstream has expressed interest in landing this fuzzer: libgit2/libgit2#4697 ; I figured I would start by trying to land an integration here, and we can move pieces into libgit2.git if and when it's stable here.
I've tagged @pks-t, a libgit2 developer who's expressed their interest, as the primary contact for now.