Skip to content

Add support for C extension fuzzing on macOS#107

Open
mschwager wants to merge 3 commits into
google:masterfrom
mschwager:mschwager-macos-c-ext
Open

Add support for C extension fuzzing on macOS#107
mschwager wants to merge 3 commits into
google:masterfrom
mschwager:mschwager-macos-c-ext

Conversation

@mschwager

Copy link
Copy Markdown

Hi all,

I recently added similar support in Ruzzy, so I thought it might be useful here too.

I also added a new target in example_fuzzers to test this functionality out and prove it's working as intended:

$ cd example_fuzzers/native_extension_example/
$ CC=/opt/homebrew/opt/llvm/bin/clang CXX=/opt/homebrew/opt/llvm/bin/clang++ CFLAGS="-fsanitize=address,fuzzer-no-link" CXXFLAGS="-fsanitize=address,fuzzer-no-link" python -m pip install --no-build-isolation --force-reinstall .
$ DYLD_INSERT_LIBRARIES="$(python -c 'import atheris; print(atheris.path())')/asan_with_fuzzer.dylib" python fuzzer.py
INFO: Using preloaded libfuzzer
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 3715284803
INFO: Loaded 1 modules   (4811 inline 8-bit counters): 4811 [0x10badac78, 0x10badbf43), 
INFO: Loaded 1 PC tables (4811 PCs): 4811 [0x10badbf48,0x10baeebf8), 
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
INFO: A corpus is not provided, starting from an empty corpus
#2	INITED cov: 60 ft: 60 corp: 1/1b exec/s: 0 rss: 68Mb
#32	NEW    cov: 61 ft: 61 corp: 2/5b lim: 4 exec/s: 0 rss: 68Mb L: 4/4 MS: 5 CrossOver-ShuffleBytes-InsertByte-InsertByte-InsertByte-
#1119	NEW    cov: 62 ft: 62 corp: 3/9b lim: 14 exec/s: 0 rss: 68Mb L: 4/4 MS: 2 ShuffleBytes-ChangeByte-
#382945	NEW    cov: 63 ft: 63 corp: 4/13b lim: 3810 exec/s: 0 rss: 96Mb L: 4/4 MS: 1 ChangeByte-
#388938	NEW    cov: 64 ft: 64 corp: 5/17b lim: 3865 exec/s: 0 rss: 96Mb L: 4/4 MS: 3 ShuffleBytes-CopyPart-CrossOver-
=================================================================
==3513==ERROR: AddressSanitizer: heap-use-after-free on address 0x60c000264d00 at pc 0x00010ba78dac bp 0x00016bdb8130 sp 0x00016bdb8128
READ of size 1 at 0x60c000264d00 thread T0
...

Comment on lines -55 to -56
- name: Install virtualenv
run: pip3 install virtualenv

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Switching to the stdlib's venv library avoids this third-party dependency.

Comment thread run_tests.sh

# Set up virtual env
"$PYTHON" -m virtualenv .
"$PYTHON" -m venv .

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Use venv here.

@mschwager

Copy link
Copy Markdown
Author

Hey @TheShiftedBit 👋, I see development of Atheris has slowed a bit. Is this project still open to outside PRs?

@TheShiftedBit

Copy link
Copy Markdown
Collaborator

Atheris already has C extension fuzzing support. I'm not sure I understand - what was the issue you were experiencing?

@mschwager

Copy link
Copy Markdown
Author

Atheris already has C extension fuzzing support. I'm not sure I understand - what was the issue you were experiencing?

As far as I can tell, C extension fuzzing is only supported on Linux:

(However, this option is not yet supported on Mac).

So this PR adds support for C extension fuzzing on macOS.

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.

2 participants