Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libafl_libfuzzer: rename all symbols #1565

Merged
merged 7 commits into from
Nov 20, 2023
Merged

libafl_libfuzzer: rename all symbols #1565

merged 7 commits into from
Nov 20, 2023

Conversation

addisoncrump
Copy link
Collaborator

@addisoncrump addisoncrump commented Sep 27, 2023

Previously we were unable to use mimalloc due to symbol conflict with the default rust allocator. This avoids this issue by renaming the symbols responsible for allocation.

Note that, in rare circumstances, we would deadlock while handling an ASAN error due to allocations inside of a signal handler. This sidesteps the issue by avoiding the use of the async-signal-unsafe malloc.

@addisoncrump addisoncrump changed the title libafl_libfuzzer: avoid panic by using mimalloc libafl_libfuzzer: avoid deadlock by using mimalloc Sep 27, 2023
@addisoncrump addisoncrump marked this pull request as draft September 27, 2023 16:16
@addisoncrump
Copy link
Collaborator Author

Seems that the target is sometimes using data from the fuzzer runtime, leading to invalid frees. Investigating.

@addisoncrump addisoncrump changed the title libafl_libfuzzer: avoid deadlock by using mimalloc libafl_libfuzzer: rename all symbols Sep 27, 2023
@addisoncrump
Copy link
Collaborator Author

In the process of doing this, I discovered that it was necessary to rename just about everything. So I did.

@addisoncrump addisoncrump marked this pull request as ready for review September 27, 2023 17:49
@tokatoka
Copy link
Member

i'll build it, run it and tomorrow morning we see if the problem still lingers.
it happens very rarely, at least last time it happened after 6 ~ 7 hours.

@tokatoka
Copy link
Member

jlumbroso/free-disk-space#17
This seems like to be the solution

@tokatoka
Copy link
Member

#1559
QEMU fuzzers are problematic. We can't run them in the same container as fuzzers (Ubuntu)
One, they take too long. Two, we shouldn't build them sequentially, there's simply no diskspace available

@tokatoka
Copy link
Member

let's see if it's fixed

@addisoncrump
Copy link
Collaborator Author

addisoncrump commented Sep 27, 2023

This affects way more than this PR 😅 Maybe make a separate PR if this works?

@tokatoka
Copy link
Member

#1567

@tokatoka
Copy link
Member

now you have clippy

@addisoncrump
Copy link
Collaborator Author

GDB and LLDB both support the new renaming pattern. c++filt, llvm-cxxfilt, and rustc-demangle do not correctly decode the renaming, but that is a sacrifice I'm willing to make.
See upstream tooling fix: rust-lang/rustc-demangle#65

@tokatoka
Copy link
Member

tokatoka commented Sep 28, 2023

should we make this default-features?

for sandwich, most people don't disable asan. so i think it's better to have this as default

let mut command = Command::new(rust_lld);
command
.args(["-flavor", "gnu"])
.arg("-r")
Copy link
Member

Choose a reason for hiding this comment

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

partial linking works with GNU ld too in case


// redefine all the rust-mangled symbols we can
// TODO this will break when v0 mangling is stabilised
for line in BufReader::new(child.stdout.take().unwrap()).lines() {
Copy link
Member

Choose a reason for hiding this comment

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

can't we just avoid to export symbols when generating the runtime lib? like partial linking and then remove all symbols

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We want to retain these symbols for both debugging purposes and because we need to retain certain unmangled symbols (e.g. LLVMFuzzerRuntime, LLVMFuzzerMutate, etc.)

@addisoncrump
Copy link
Collaborator Author

should we make this default-features?

This is always enabled on Unix. Not sure how to do this on Windows.

@addisoncrump addisoncrump force-pushed the libfuzzer-allocator branch 2 times, most recently from 32a749b to 02d8b87 Compare October 4, 2023 15:56
@andreafioraldi
Copy link
Member

Status of this?

@addisoncrump
Copy link
Collaborator Author

Just fighting the CI at this point. Something weird is happening with the FreeBSD test.

@domenukk
Copy link
Member

domenukk commented Nov 3, 2023

Can we merge?

@addisoncrump
Copy link
Collaborator Author

This is ready to go if anyone wants to give it a final pass.

@domenukk domenukk merged commit 1e96652 into main Nov 20, 2023
17 checks passed
@domenukk domenukk deleted the libfuzzer-allocator branch November 20, 2023 20:55
tokatoka pushed a commit that referenced this pull request Nov 21, 2023
* rename allocator symbols to avoid conflict with mimalloc

* re-add llvm-tools to CI

* rename everything

* fixup clippy lint

* make fuzzer entries more noticeable :)

* rabbit mode

* clippy
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.

4 participants