fix(fuzz): correct oss-fuzz/build.sh's fragroute linking, prep for submission (#1092) - #1114
Merged
Merged
Conversation
…bmission (#1092) Two real bugs, found by actually running this script rather than reading it: - FUZZ_LIBS hardcoded src/fragroute/libfragroute.a unconditionally, so a build where fragroute isn't available (no libdnet) would fail linking fuzz_services/fuzz_pcap too, over a library neither of them needs. - The libdnet link flag was hardcoded as -ldnet. Debian/Ubuntu - including OSS-Fuzz's own base-builder image - package it as libdumbnet, so linking ever actually reaches this by accident, not because -ldnet resolves there. Read the real flag (LDNETLIB) back out of test/fuzz/Makefile instead, which is what ./configure, run two lines above, already determined. Also uses $WORK for intermediate object files rather than /tmp, matching what OSS-Fuzz's own documented environment contract calls it. Verified end-to-end outside the OSS-Fuzz container (no Docker available here): ran this exact script with $CC=clang, $CXX=clang++, and $CFLAGS/$CXXFLAGS/$LIB_FUZZING_ENGINE set to what OSS-Fuzz would supply (ASan+UBSan, -fsanitize=fuzzer) against a fresh checkout. All three targets built, ran cleanly against the checked-in corpus, and ran several million fuzzing iterations apiece in a few seconds with no crashes. project.yaml: dropped the memory (MSan) sanitizer - fuzz_fragroute/fuzz_pcap link the base image's apt-installed libpcap/libdumbnet, not rebuilt with MSan instrumentation, so it would flag uninitialized-value use inside libraries that aren't ours to fix; our own CI's asan job made the same call (ASan+UBSan only). Also noted the branch-pin caveat (#1092): the actual submission clones 4.6.1-beta1, not this repo's default branch, since the fuzz targets haven't reached master yet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixing this ahead of actually submitting to OSS-Fuzz (#1092), since testing it turned up two real bugs.
What was wrong
Actually running
test/fuzz/oss-fuzz/build.sh(rather than just reading it) found:FUZZ_LIBShardcodedsrc/fragroute/libfragroute.aunconditionally, so a build where fragroute isn't available (no libdnet) would fail linkingfuzz_services/fuzz_pcaptoo, over a library neither of them needs.-ldnet. Debian/Ubuntu - including OSS-Fuzz's ownbase-builderimage - package it aslibdumbnet. Confirmed locally:dumbnet-config --libs→-ldumbnet, and the flag-ldnetdoesn't resolve to anything on this system at all.Fixed by reading the actual link flag (
LDNETLIB) back out oftest/fuzz/Makefile, which./configure(run two lines above in the same script) already determined correctly - rather than guessing at a hardcoded flag a second time.Also switched intermediate object files from
/tmpto$WORK, matching OSS-Fuzz's documented environment contract ($WORK: "directory for intermediate build files").Verification
No Docker available in this environment, so I couldn't run the actual OSS-Fuzz container. Instead, ran the corrected script directly with the exact environment variables OSS-Fuzz supplies:
against a completely fresh checkout (autogen → configure → make → manual compile+link, exactly as the script does). All three targets (
fuzz_services,fuzz_pcap,fuzz_fragroute) built, ran cleanly against the checked-in corpus, and ran several million fuzzing iterations apiece in a few seconds with no crashes:project.yaml
memory(MSan):fuzz_fragroute/fuzz_pcaplink the base image's apt-installedlibpcap/libdumbnet, not rebuilt from source with MSan instrumentation, so MSan would flag uninitialized-value use inside libraries that aren't ours to fix. Same call our own CI'sasanjob already makes (ASan+UBSan only).4.6.1-beta1, not this repo's default branch, since the fuzz targets haven't reachedmasteryet - flagged so whoever eventually merges that release remembers to update the Dockerfile too.🤖 Generated with Claude Code
https://claude.ai/code/session_01NBmWiWg46r8BLbdwozKo6v