This is an archive of the discontinued LLVM Phabricator instance.

[libFuzzer] Add support for Fuchsia OS
ClosedPublic

Authored by aarongreen on Dec 7 2017, 11:09 AM.

Details

Summary

This patch adds the initial support for Fuchsia.

Summary of changes:

  • LIBFUZZER_FUCHSIA is added as an OS type in FuzzerDefs.h
  • Fuchsia is, by design, not POSIX compliant. However, it does use ELF and supports common POSIX I/O functions. Thus, FuzzerExtFunctions.h and FuzzerIO.h are implemented by extending the header guards in FuzzerExtFunctionsWeak.cpp and FuzzerIOPosix.cpp to include LIBFUZZER_FUCHSIA.
  • The platform-specific portions of FuzzerUtil.h are implemented by FuzzerUtilFuchsia.cpp, which makes use of exception ports, syscalls, and the launchpad library.
  • The experimental equivalence server is not currently supported, so FuzzerShmem.h is implemented by stub methods in FuzzerShmemFuchsia.cpp. Any future implementation will likely involve VMOs.

Tested with ASAN/SanCov on Fuchsia/x86-64 with the canonical toy fuzzer.

Diff Detail

Event Timeline

aarongreen created this revision.Dec 7 2017, 11:09 AM
aarongreen edited the summary of this revision. (Show Details)
kcc edited edge metadata.Dec 7 2017, 11:15 AM

Common code LGTM

Please get the review for FuzzerUtilFuchsia.cpp and I'll land it.

Will you need a change in CMakeLists.txt FuzzerUtilFuchsia.cpp?
Or you are using a different build?

lib/fuzzer/FuzzerShmemFuchsia.cpp
11

Totally fine.
The equivalence server functionality haven't been used by anyone (AFAICT), so it's a candidate for deletion.

lib/fuzzer/FuzzerUtilFuchsia.cpp
2

Please have this file reviewed on your side. (flowerhack?)

Eugene.Zelenko added inline comments.
lib/fuzzer/FuzzerShmemFuchsia.cpp
13

Please separate with empty line.

lib/fuzzer/FuzzerUtilFuchsia.cpp
12

Please separate with empty line.

16
19
aarongreen updated this revision to Diff 126045.Dec 7 2017, 2:21 PM
aarongreen marked 5 inline comments as done.

Add cmake hooks.
Addressed formatting comments.

phosek edited edge metadata.Dec 7 2017, 11:52 PM

LGTM % a few nits

lib/fuzzer/FuzzerIOPosix.cpp
12

This is probably fine for now but eventually we'll probably need FuzzerIOFuchsia.cpp since some of the things in this file doesn't make sense on Fuchsia, e.g. IsInterestingCoverageFile.

lib/fuzzer/FuzzerUtilFuchsia.cpp
53

nit: you can probably just do while (getchar() != 0x03);.

161

You should probably do this above on line 153.

aarongreen updated this revision to Diff 126169.Dec 8 2017, 9:32 AM
aarongreen marked 2 inline comments as done.

Address phosek's comments.

kcc accepted this revision.Dec 8 2017, 1:46 PM

Matt, please land.

This revision is now accepted and ready to land.Dec 8 2017, 1:46 PM
This revision was automatically updated to reflect the committed changes.